There are many functions for reading URL parameters in JavaScript on the Internet, but I didn't take into account the # character in the URL. I can handle this situation and use the dot object writing method to optimize some performance.
Function getUrlArg (seekArg) {var url = location. href; // use a regular expression to separate the parameters between the question mark and the well number, such as from the http://www.jb51.net/testjs.htm? P = 1 & t = 1 & u = 1 # p = 1 & t = 1 & u = 1 if (reMatch = url. match (/\? ([^ #] + )#? /) {Var querystring = reMatch [1]; // use the Regular Expression & OR = to split the string into an array. The args array contains the variable name and variable value in sequence, such as p, 1, t, 2, u, 24 var args = querystring. split (/& | =/); // The arg must be declared as an object. If only var arg is written, an error is reported when the variable arg is assigned. var arg ={} is not defined {}; for (I = 0; I
[Ctrl + A select all Note: If you need to introduce external Js, You need to refresh it to execute]