Turn from: http://blog.csdn.net/maxracer/article/details/7030903
decodeURI () Definition and usage: the decodeURI () function decodes the URI encoded by the encodeURI () function.
Syntax: decodeURI (uristring)
Parameter description: Uristring required, a string containing the URI group to decode or other text to decode.
Return value: A copy of the uristring in which the hexadecimal escape sequence is replaced by the character they represent.
decodeURIComponent () Definition and usage: the decodeURIComponent () function decodes the URI encoded by the encodeURIComponent () function.
Syntax: decodeURIComponent (uristring)
Parameter description: Uristring required, a string containing the decoded URI component or other text to decode.
Return value: A copy of the uristring in which the hexadecimal escape sequence is replaced by the character they represent.
<body>
<script type= "Text/javascript" >
var test = "Http://www.test.com/My test/";
var test1 = encodeURI (test);
var test2 = decodeURI (test1);
var test3 = encodeuricomponent (test);
var test4 = decodeuricomponent (TEST3);
document.write (test1 + "<br/>");
document.write (test2 + "<br/>");
document.write (test3 + "<br/>");
document.write (test4 + "<br/>");
</script>
</body>
Run Result:
http://www.test.com/My%20test/
http://www.test.com/My test/
http%3a%2f%2fwww.test.com% 2fmy%20test%2f
http://www.test.com/My test/