JavaScript code involves three functions: Escape, encodeuri, and encodeuricomponent. The corresponding three decoding functions are: Unescape, decodeuri, and decodeuricomponent.
1. encodeuricomponent is required when passing parameters so that the combined URL will not be truncated by special characters such.
Example: <script language = "JavaScript"> document. Write ('<a href = "http://passport.baidu.com /? Logout & Aid = 7 & U = '+ encodeuricomponent ("http://cang.baidu.com/bruce42") +' "> exit </a> '); </SCRIPT>
2. encodeuri can be used for URL redirection.
Example: location. href = encodeuri ("http://cang.baidu.com/do/s? WORD = Baidu & Ct = 21 ");
3. You can use escape when JS uses data.
[Edit huoho. com]
For example, search for the history record in the bucket.
4. When encoding Unicode values other than 0-, escape outputs % u *** format. In other cases, escape, encodeuri, and encodeuricomponent have the same encoding result.
The most commonly used format is encodeuricomponent, which converts special characters such as Chinese and Korean into UTF-8 URL encoding, therefore, if you want to use encodeuricomponent to transmit parameters to the backend, you must use backend decoding to support UTF-8 (the encoding method in form is the same as that on the current page)
Escape unencoded characters are 69: *, +,-,.,/, @, _, 0-9, A-Z, A-Z
Encodeuri is not encoded with 82 characters :!, #, $, &, ', (,), *, +,-,.,/,:,;, = ,?, @,_,~, 0-9, A-Z, A-Z
Encodeuricomponent has 71 unencoded characters :!, ',(,),*,-,.,_,~, 0-9, A-Z, A-Z