1. Basic Concepts
encodeuri and decodeuri are used in pairs because the address bar of the Browser contains Chinese characters, unexpected errors may occur, so encodeuri can convert non-English characters into English encoding, and decodeuri can be used to restore the characters. The encodeuri method does not encode the following characters: ":", "/", ";", and "? The encodeuricomponent method can encode these characters.
the decodeuri () method is equivalent to java.net. urldecoder. decode (uristring, "UTF-8");
the encodeuri () method is equivalent to java.net. urlencoder. encode (uristring, "UTF-8");
Ii. Example
<SCRIPT type = "text/JavaScript">
VaR uristr = "http://www.baidu.com? Name = John & num = 001 Zs ";
VaR uriec =Encodeuri(Uristr );
Document. Write ("encoded" + uriec );
VaR uridc =Decodeuri(Uriec );
Document. Write ("decoded" + uridc );
</SCRIPT>
Encoded http: // www.Baidu. Com? Name = % E5 % BC % A0 % E4 % B8 % 89 & num = 001% 20zs
Decoded http: // www.Baidu. Com? Name = zhangsan & num = 001 Zs
reference address: http://blog.csdn.net/hnwangdan/article/details/5968657