encode/decodeURI,encode/decodeURIComponent
测试代码
1.html:
执行结果<html> <body> <script type="text/javascript"> var urlStr="http://www.abc.com/good boy/"; var aa=encodeURI(urlStr); var cc=decodeURI(urlStr); document.write(aa+ "<br />"); document.write(cc+ "<br />"); var bb=encodeURIComponent(urlStr); var dd=decodeURIComponent(bb); document.write(bb+ "<br />"); document.write(dd); </script> </body> </html>
http://www.abc.com/good%20boy/ http://www.abc.com/good boy/ http%3A%2F%2Fwww.abc.com%2Fgood%20boy%2F http://www.abc.com/good boy