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

Recommended Today

Looking for frustration 1.0

I believe you have a basic understanding of trust in yesterday’s article. Today we will give a complete introduction to trust. Why choose rust It’s a language that gives everyone the ability to build reliable and efficient software. You can’t write unsafe code here (unsafe block is not in the scope of discussion). Most of […]