A JavaScript function, parseQueryString, is used to parse URL parameters into an object. It is very practical. You can check the problem: compile a JavaScript function, parseQueryString, it resolves URL parameters into an object.
Eg: var obj = parseQueryString (url );
Three Forms of object creation:
I:
var Person=new Object();Person.name="Sun";Person.age=24;
II:
var Person=new Object();Person["name"]="Sun";Person["age"]=24;
III:
Object literal expression
var Person={name: "Sun",age: 24}
PS:
1. In this example, it is better to use the second form to add elements to obj.
2. split ("&"). If there is only one parameter in the url and there is no "&", no error is reported. Only array [0] is returned.
function parseQueryString(url){var obj={};var keyvalue=[];var key="",value=""; var paraString=url.substring(url.indexOf("?")+1,url.length).split("&");for(var i in paraString){keyvalue=paraString[i].split("=");key=keyvalue[0];value=keyvalue[1];obj[key]=value; } return obj;}