one: JS URL in the transfer of Chinese parameter garbled problem, Focus: encodeURI encoding, decodeURI decoding:
1. Pass the parameter 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;//Access URL
var userName = Urlinfo.split ("?") [1].split ("=") [1];//split URL gets the parameters after "="
$ ("#userName"). HTML (decodeURI (userName));
</script>
two: How to get the URL. After, the parameter value of ' = ':
A. Get the full URL value first with window.location.href.
B. Use split to intercept "?" After the whole
C.split ("?") number in [1] later, default starting from 0
three: JS in escape,unescape,encodeuri,encodeuricomponent difference:
1. Pass the parameter time to use, encodeuricomponent otherwise the URL is very easy to be "#", ". "," & "and other sensitive symbols partition.
2.url jump time to use, coding with encodeURI, decoding with decodeURI.
3.escape () only for 0-255 ASCII characters to do conversion work, converted to%u**** such code, if you want to use more characters Furu UTF-8 Word library must use encodeURIComponent () or encodeURI () conversion can be% Nn%nn This code can be, in other cases escape,encodeuri,encodeuricomponent coding results are the same, so for the global unification process, in the encodeURIComponent () or encodeURI () instead Escape () use it.
Turn from: http://www.wufangbo.com/js-url-zhong-wen-luan-ma/