梦之都
JavaScript教程
encodeURIComponent
函数,转义某些字符串对URI的组件编码
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>JavaScript encodeURIComponent() 函数示例</title> </head> <body> <script type="text/javascript"> var str="梦之都 http://www.dreamdu.com/"; str=encodeURIComponent(str); document.write(str); document.write("<br />"); str=decodeURIComponent(str); document.write(str); document.write("<br />"); str=encodeURI(";/?:@&=+$,#-_.!~*'()"); document.write(str); document.write("<br />"); str=encodeURIComponent(";/?:@&=+$,#-_.!~*'()"); document.write(str); </script> </body> </html>