Let's go straight to the code.
//The parameters in the URL are captured and replaced with the JSON format function serilizeurl (URL) {var urlobject={}; 1. Is the regular match for? The End if (/\?/.test (URL)) {//substring intercepts the string between the specified position,//The first value is the starting subscript, the second one does not write,//does not write until the last//2. Intercept? The thing behind var urlstring = url.substring (Url.indexof ('? ') +1)//3. Add & Remove to array var Urlarray = Urlstring.split ("&"); 4. Traversing the array for (Var i=0;i<Urlarray. length;i++) {var Urlitem= Urlarray[i]; //Cut VAR item again=urlitem[i].split (' = '); //Assign Value urlobject[item[0]]=item[1]; } return urlobject; }//returns NULL if there is no match on it;
My code comments are more detailed, mainly to give beginners a reference.
Method of extracting parameters in URL (converted to JSON format)