from a page through the URL to the B page, get the URL of the parameters in Chinese garbled problem, the correct way to parse the URL parameters are as follows, interested friends can refer to the following
When you pass a page through a URL to page b, the parse URL parameter can be: in the following two ways: regular analysis code as follows: function getquerystring (name) { var reg = new RegEx P ("(^|&)" + name + "= ([^&]*) (&|$)", "I"); var r = window.location.search.substr (1). Match (REG); if (r!= null) return unescape (r[2]); Return null; } This calls: code as follows: Alert (getquerystring ("parameter name 1")); alert (getquerystring ("parameter Name 2") ; alert ("Parameter name 3"); method Two: code is as follows: <span style= "FONT-SIZE:16PX;" ><script language= "javascript" > function getrequest () { var url = location.search;//Get URL "?" Character string var therequest = new Object (); if (Url.indexof ("?")!=-1) { var str = url.substr (1); STRs = Str.split ("&"); for (var i = 0; i < strs.length i + +) { therequest[strs[i].split ("=") [0]]=unescape (str S[i].split ("=") [1]); } } return therequest; } </Script></span> This calls the: code as follows: <SCRIPT language= "javascript" > var request = new Object (); request = Getrequest (); var parameter 1, Parameter 2, parameter 3, parameter n;& nbsp Parameter 1 = request[' parameter 1 ']; parameter 2 = request[' parameter 2 ']; parameter 3 = request[' parameter 3 ']; parameter n = request[' parameter n ']; </scrip t> If the parameter contains Chinese characters, note the transcoding and decoding: code as follows: <span style= "FONT-SIZE:18PX;" >1. Parameters page JavaScript code: <script type= "Text/javascript" > 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;//Get url var userName = Urlinfo.split ("?") [1].split ("=") [1];//the split URL gets the parameter after "=" $ ("#userName"). HTML (decodeURI (userName)); </script></ span>