Summary:This article is about two decoding functions, they are the decodeURI () and decodeURIComponent () functions, these two functions can be generated by a particular function of the cryptographic string decryption operation, it can be produced as an unencrypted string, more practical, the following
This article is about two decoding functions, they are the decodeURI () and the decodeURIComponent () function, these two functions can be generated by a particular function of the cryptographic string decryption operation, it can be born into an unencrypted string, more practical, Let's take a look at the usage and examples of these two functions, and you'll use:
decodeURI () Definition and usage: the decodeURI () function decodes a URI encoded by the encodeURI () function.
Syntax: decodeURI (uristring)
Parameter description: uristring required. A string that contains the URI to decode or other text to decode.
Return value: A copy of uristring, where 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 that contains the encoding URI component or other text to decode.
Return value: A copy of uristring, where the hexadecimal escape sequence is replaced by the character they represent.
Instance:
- <html>
- <body>
- <script type="Text/javascript">
- var test1="Http://www.wljcz.com/My first/";
- var nn=encodeURI (test1);
- var now=decodeURI (test1);
- document.write (nn+ "<br />");
- document.write (now);
- var test1="Http://www.wljcz.com/My first/";
- var bb=encodeURIComponent (test1);
- var nnow=decodeuricomponent (BB);
- document.write (bb+ "<br />");
- document.write (Nnow);
- </Script>
- </body>
- </html>
The result of this operation is:
http://www.wljcz.com/My%20first/
Http://www.wljcz.com/My first/
http%3a%2f%2fwww.wljcz.com%2fmy%20first%2f
Http://www.wljcz.com/My first/
Reprint: http://blog.csdn.net/luqin1988/article/details/7878053
JS in decodeURI () and decodeURIComponent ()