devxlogo

An Improved escape() Function in Javascript

An Improved escape() Function in Javascript

Currently Javascript’s escape() has some limitations. For instance, if you want to pass a+b not a b, you want to get the literal “+” in the server side. Javascript’s escape function does not replace the “+” with a hexadecimal value, so when it is received on the server, it will be treated as a blank space rather than as a “+.” The function below will replace all special characters with hexadecimal format functions just like ASP’s Server.URLEncode() function.

 function urlencode(strValue) {	var charValue,blnValidChar,charCodeValue;	var strEncodedValue='';	for(var i=0;i

devx-admin

Share the Post: