one, Escape
1, the characteristic function is lets the string be readable on all computers. The effect of the encoding is%XX or%uxxxx this form.
encoded character range: ASCII letters, numbers, @*/+, these characters will not be encoded, the rest will be.
2, suitable for the occasion
Strings Two, encodeURI 1, and feature spaces are encoded as "%20" encoded character ranges: ASCII letters, numbers, ~!@#$&* () =:/,;? + ' will not be coded, the other will be 2, suitable for the occasion
Because encodeURI does not encode ":" and "/" in the URL, use encodeURI if you need to encode and use the entire URL.
encodeURIComponent cannot be used because encodeURIComponent will encode ":" In the URL as "%3a" and "/" to encode "%2f"
This URL will not be accessible. Third, encodeURIComponent 1, features encoded character range: ASCII letters, numbers, ~!* () will not be encoded, others will be compared encodeURI can be found encodeuricomponent than encodeURI coding range. encodeURIComponent will encode http://as http%3a%2f%2f and encodeURI not. 2, suitable for the occasion
When you need to encode the parameters in the URL, then encodeURIComponent is the best way.
Because the "/" in the URL parameter needs to be encoded, otherwise an invalid path is created in the URL that affects access to the URL.
encodeURIComponent can encode "/", so it is appropriate to encode the parameters of the pairs in the URL.
encodeURI cannot encode "/", so it is not appropriate to encode the parameters in the URL.