varURLs = Window.location.search;//get the URL? The following path (parameter)functionUID (string) {if(String.IndexOf (' = ') < 0) {//use the IndexOf method to determine if there are no parameters behind the URL, that is, <0 return{};//returns an empty object to prevent an error} string= String.substr (String.IndexOf ('? ') + 1, string.length);//string assignment using the Substr method to intercept from? The last one begins, to the end if(String.IndexOf (' # ') > 0) {//determine the URL after the # number is worth the situationstring = String.substr (0, String.IndexOf ("#"));//string Assignment intercept starts at 0 and ends at # } varobj = {},//defines the Obj object, the JSON object format, for storing the converted parameter objectPairs = String.Split (' & '),//define pairs = URL with & SplitD = decodeuricomponent;//the alias of the D decodeURIComponent method, which is called below$.each (Pairs,function(I, pair) {//use the each () methodPair = pair.split (' = ');//assigning a pair with an equal-value partition varName = d (Pair[0]);//assign a value to name varValue = d (pair[1]);//assigning values to valueObj[name] = value;//assigning a value to obj }); returnObj//return the above resultsNote: The string here is not defined outside because it is defined internally and created automatically when needed (equivalent to local variables)
Methods for fetching URL parameters