A: JS URL to pass the Chinese parameter garbled problem, Focus: encodeURI encoding, decodeURI decoding:
1. Pass the reference page
JavaScript code:
<script type= "Text/javascript" > function Send () { var url = "test01.html" ; var userName = $ ("#userName"). html (); + "? username=" + userName)); } </script>
2. Receive Parameters page: test02.html
<script> var urlinfo = window.location.href; get URL var userName = Urlinfo.split ("?") [1].split ("=") [1]; // split URL to get parameters after "=" $ ("#userName"). HTML (decodeURI (userName)); </script>
Two: How to get the url "? "After," = "parameter value:
A. First get the full URL value with Window.location.href
B. Using split to intercept "?" After the all
C.split ("?") number in [1] later, calculated by default starting from 0
Three: JS in the escape,unescape,encodeuri,encodeuricomponent difference:
1. Pass parameters when used, encodeuricomponent otherwise the URL is easily "#", "?" "," & "and other sensitive symbols partition.
2.url Jump time use, encoding with encodeURI, decoding with decodeURI.
3.escape () Just for the 0-255 ASCII characters to do the conversion work, converted to%u**** such a code, if you want to use more words such as UTF-8 word repertoires must use encodeURIComponent () or encodeURI () conversion can be% Nn%nn This code can, in other cases escape,encodeuri,encodeuricomponent encoding results are the same, so for the global unification process, in the use of encodeURIComponent () or encodeURI () instead Escape () Use it!
This article transferred from: http://www.wufangbo.com/js-url-zhong-wen-luan-ma/
JS URL to pass the Chinese parameter garbled, how to get the URL parameter problem