Reputation: 39
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.
Upvotes: 1
Views: 874
Reputation: 324497
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.
Upvotes: 6