// JS get query parameter name: query parameter name
Function geturlparam (name ){
VaR Reg = new Regexp ("(^ | &)" + name + "= ([^ &] *) (& | $ )");
VaR r = Window. Location. Search. substr (1). Match (REG );
If (R! = NULL)
Return Unescape (R [2]);
Return NULL;
}
Assume that the current page isHttp://www.cnblogs.com/zhengrunqiang/admin/EditPosts.aspx? Opt = 1
If you need to obtain the value of the OPT parameter in the front-end JS Code on the current page
First introduce the following section
<SCRIPT type = "JavaScript">
// JS get query parameter name: query parameter name
Function geturlparam (name ){
VaR Reg = new Regexp ("(^ | &)" + name + "= ([^ &] *) (& | $ )");
VaR r = Window. Location. Search. substr (1). Match (REG );
If (R! = NULL)
Return Unescape (R [2]);
Return NULL;
}
$ (Document). Ready (function (){
VaR opt = geturlparam ("Opt ");
Alert (OPT );
});
</SCRIPT>
Result: 1