Package getQueryString () method to get the Value value of the URL

Scan the QR code to enter the page, and intercept the value after the url “?”. The url is…/monitorScreen/category.html?ridgeCode=ZT1S010005

< pre>function getQueryString(name) {

var reg = new RegExp(“(^| &)” + name + “=([^&]*)(&|$)”, “i”);

var url = window.location.search;

var r = url.substr(1).match(reg) ;

if(r != null) return unescape(r[2]);

return null;

}

var code = getQueryString(‘ridgeCode’);

The printing code is ZT1S010005

function getQueryString(name) {

var reg = new RegExp("(^| &)" + name + "=([^&]*)(&|$)", "i");
var url = window.location.search;
var r = url.substr(1).match(reg) ;
if(r != null) return unescape(r[2]);
return null;
}
var code = getQueryString(‘ridgeCode’);

Leave a Comment

Your email address will not be published.