The coding and decoding method of Javascript--uri

Source: Internet
Author: User

Valid URIs (Uniform Resource Identifiers) cannot contain certain characters, such as spaces, so they need to be encoded in the following ways: encodeURI () and encodeURIComponent (),

The decoding methods of the coded codes are: decodeURI () and decodeURIComponent ().

encodeURI () coding can only decodeURI () solution

encodeURIComponent () code can only decodeuricomponent () solution,

encodeURI (): Used to encode a complete URI that does not encode special characters in a URI: for example, a colon, a forward slash, a question mark, a pound sign

var str0=encodeuri ("http://www.cnblogs.com/2012/71.html"); // results: http://www.cnblogs.com/%202012/%2071.html     
      The spaces are encoded only

encodeURIComponent (): Used to encode a portion of a URI that encodes all non-standard characters in a URI

var str1=encodeuricomponent ("http://www.cnblogs.com/2012/71.html"); // results: http%3a%2f%2fwww.cnblogs.com%2f%202012%2f%2071.html

The coding and decoding method of Javascript--uri

Related Article

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.