Spent a long vacation, just back to the company some do not adapt to the previous study plan and work plan have been interrupted, come back don't know what to do. So I ran to see my colleague's blog, and then came back to read the notes before you, then continue to learn JavaScript.
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
Encode all non-standard characters
The coding and decoding method of Javascript--uri