views:

93

answers:

4

hi, i am passing a path as an argument in a javascript. for example i am passing a path as c:\my documents\user\aa.jpg when registering javascript in client side.

but when calling this in a function say, function js(d) then the slash goes missing..hence the value of 'd' becomes c:mydocumentsuseraa.jpg

what to do?

thanks

A: 

I think you need to pass your value in single quote

'c:\my documents\user\aa.jpg'
Muhammad Akhtar
A: 

Have you escaped your backslashes ?

alert( 'c:\\my documents\\user\\aa.jpg' );
Ploufka
+1  A: 

pass it like this:

c:\\my documents\\user\\aa.jpg

you need to escape the slash char. thanks

You should always pass the slash char which has special meaning for example, you can use it to specify new lines like \n, tabs \t, etc. So you should escape it with another slash char to make it come single slash char.

Sarfraz
A: 

You said when registering javascript in client side.

I assume you are doing this in the code behind as you have tagged asp.net. So I think you would need to use @ before the string while registering the scipt.

Like @"c:\abc\xyz.jpg"

OR you can go by the method Sarfraz mentiond. i.e. pass the string as "c:\\abc\\xyz.jpg"

I hope this helps.

Manish