JavaScript gets the regular expression of URL parameter (used to get a parameter value)


//JavaScript parameters (multiple)
var url = “B.aspx?txtA=”+document.getElementById(“txtName”).value;
url +=”&txtB=”+document.getElementById(“txtAge”).value;,’xWindow’,’width=640,height=400,status=no,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=no,top=250,left=430′);
//B. Aspx target page

Copy codeThe code is as follows:
<scirpt language=’javascirpt’>
function GetStringValue()
String. Prototype. Getquerystring = function (name) / / name is the parameter name of the URL
var reg = new RegExp(“(^|&|\\?)”+ name +”=([^&]*)(&|$)”), r;
if (r=this.match(reg)) return unescape(r[2]); return null;
//You can get the parameter value by passing the parameter name directly

Difference between and window.location:
Window. Open is to open a new window
Window. Location is the replacement of this page, that is, location
JavaScript URL parameter reading improved version