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" >//<! [cdata[
function Send () {
var url = "Test01.html";
var userName = $ ("#userName"). html ();
window.open (encodeURI (url + "? username=" + UserName)); }
]]>
</script>
2. Receive Parameters page: test02.html
<script>
var urlinfo = window.location.href;//Fetch URL
var userName = Urlinfo.split ("?") [1].split ("=") [1];//split URL to get the "=" side of the parameters
$ ("#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!
Can be reproduced arbitrarily, please be sure to use hyperlinks in the form of the original source of the article and this statement
This address: http://www.weiking.com.cn/post/654.html
JS URL to pass the Chinese parameter garbled, how to get the URL parameter problem