tags:

views:

97

answers:

2

Hi All:
I have an url link "Change", a pop up window will get open when the user clicks the link. During that time, some parameters with values also sending in the url. Some parameter values contains special characters (' eg: &name=D'LOREY&lname=VALENTINE). If the value is full of alphabets it is working fine but throwing javascript error when the value contains special character. Please help to resolve this issue. Thanks in advance.

A: 

Look up the Javascript built-in escape function.

Pointy
According to http://xkr.us/articles/javascript/encode-compare/ (the accuracy of which I cannot vouch for), `escape` is broken, use `encodeURIComponent`.
bdukes
+6  A: 

Use encodeURIComponent on both the name and the value for your parameter. It's supported in all the mainstream desktop browsers going back to IE 5.5. If you need to support IE 5, you'll have to make do with escape, which as noted elsewhere is not perfect.

Tim Down