Of course, we can get the parameter value in the background, and then get the variable value in the front-end js Code. For details, refer to my article: javaScript obtains the C # variable in the background and calls the background method.
In fact, we can also directly obtain the value of the Request Parameter in js. By using window. location. search, we can get the current URL? A string starting with "#". For example, the search result obtained from the previous link is? Id = 001. Then process the obtained string to obtain the parameter value.
Copy codeThe Code is as follows:
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;
}
When calling the preceding method, you only need to input the parameter name to obtain the value of the parameter you want, for example, getUrlParam ("id ").