Handling Special Chars in javascript

Satish
Posted by in JavaScript category on for Beginner level | Views : 9892 red flag

I was wondering how to handle special chars in the query string when redirecting the page to a different page with the help of Javascript. I thought of sharing this snippet.
Hope this will help you guys...

Here javascript escape is used to encode the string and unescape is to decode the string in Javascript.

var vstr = escape("It's wounderful!")

alert(vstr);
alert(unescape(vstr));


If you wanna handle this at server side use the following code.

string str = Server.UrlDecode(Request.QueryString["trial"]);

or
string str = Server.UrlEncode(Request.QueryString["trial"]);

Page copy protected against web site content infringement by Copyscape

About the Author

Satish
Full Name: Satish Kumar
Member Level: Starter
Member Status: Member
Member Since: 6/29/2007 10:01:12 AM
Country:


Happy Coding...

Login to vote for this post.

Comments or Responses

Login to post response

Comment using Facebook(Author doesn't get notification)