1.html:
<a href= "2.html?name=geovindu&sex=woman&age=12" >test getquerystring</a>
2.html:
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "> Js1.js:
/*http://css.dusystem.com/example/index.htmlwindow.location.protocol = "http:" Window.location.host = " css.dusystem.com "window.location.pathname =" example/index.html "http://stackoverflow.com/questions/901115/ how-can-i-get-query-string-values-in-javascripthttp://www.cnblogs.com/sohighthesky/archive/2010/01/21/1653126. Htmlhttp://www.codeproject.com/tips/574956/how-to-get-url-and-querystring-value-in-an-asp-nettest: <a href= " 1.html?id=5&type=1&flag=0 "title=" D ">test</a>*///script Paramter:var getScriptArgs=function () {// Get multiple parameters var scripts=document.getelementsbytagname ("script"), script=scripts[scripts.length-1],// Because the script tag is not loaded after the current DOM is loaded, the last one is the current script src=script.src, reg=/(?: \?| &) (. *?) =(.*?) (? =&|$)/g, temp,res={}; while ((Temp=reg.exec (SRC))!=null) res[temp[1]]=decodeuricomponent (temp[2]); Return res;};/ /var Argsscript=getscriptargs ();//document.getelementbyid ("Scriptparamter"). InnerHTML =argsscript.a+ "| "+argsscript.b+" | "+argsscript.C;alert (argsscript.a+ "| "+argsscript.b+" | "+ARGSSCRIPT.C"//If the above JS is in this js1.js script <script type= "Text/javascript" src= "js1.js?a=abc&b= kanji &c=123//" ><//script>var getscriptarg=function (key) {//Get a single parameter var scripts=document.getelementsbytagname ("script"), Script=scripts[scripts.length-1], src=script.src; Return (Src.match new RegExp (?: ^\ \?| &) "+key+" = (. *?) (? =&|$))) | | ["', NULL]) [1];}; Alert (Getscriptarg ("C"));
How do I get the query string by JavaScript?