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