var LocString = String(window.document.location.href); function getQueryStr(str) { var rs = new RegExp("(^|)" str "=([^&]*)(&|$)", "gi").exec(LocString), tmp; if ( tmp = rs) { return tmp[2]; } // parameter cannot be found return ""; }
<script> <br>urlinfo=window.location.href; //Get the url of the current page <br>len=urlinfo.length;//Get the url Length<br>offset=urlinfo.indexOf("?");//Set the starting position of the parameter string<br>newsidinfo=urlinfo.substr(offset,len)//Remove the parameter string and you will get something like "id= 1" such a string<br>newsids=newsidinfo.split("=");//Split the obtained parameter string according to "="<br>newsid=newsids[1];//Get the parameter value<br>alert("The parameter value you want to pass is " newsid); <br></script>
But be sure to remember that this method is only useful for urls that contain parameters. If the other party uses If you use the POST method to pass parameters, the URL will not contain parameters, so this technique is only useful for the GET method or the URL with specified parameters
Look at a complete example below
aa.htm It is the parameter input and infiltration interface bb.htm is the parameter receiving and processing interface aa.htm