JS in decodeURI () and encodeURI () differences, decodeuricomponent and encodeuricomponent differences

Source: Internet
Author: User

decodeURI () Definition and usage: the decodeURI () function decodes a 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 uristring, where the hexadecimal escape sequence is replaced by the character they represent.

decodeURIComponent () Definition and usage: the decodeURIComponent () function decodes a URI encoded by the encodeURIComponent () function.
Syntax: decodeURIComponent (uristring)
Parameter description: Uristring required, a string that contains the decoded 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.

The above is a description of the usage, but there are some problems in the actual use process:

#特殊符号进行进行编码传递参数的时候有一些不一样:

Test code as follows:

<Script>functionDemo () {vartext=Escape ("http://www.w3school.com.cn/My first/#qpp"); alert (text);}functiondemo1 () {vartest1="http://www.w3school.com.cn/My first/#qpp"alert (encodeURIComponent (test1));}functionDemo3 () {vartest1="http://www.w3school.com.cn/My first/#qpp"alert (decodeURI (test1));}functionMyApp (text) {vartext=unescape (text); alert (text);} 

JS decodeURI () and encodeURI () differences, decodeuricomponent and encodeuricomponent differences

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.