/*
* For querystring (such? Userid = 222 & username = 23432sdf) Processing
*/
Function PageQuery (q ){
If (q. length> 1)
This. q = q. substring (1, q. length );
Else
This. q = null;
// Define a key-Value Pair
This. keyValuePairs = new Array ();
If (this. q ){
Var infos = this. q. split ("&");
For (var I = 0; I <infos. length; I ++ ){
// Add parameters to the array
This. keyValuePairs. push (infos [I]);
}
}
This. getKeyValuePairs = function () {return this. keyValuePairs };
// Obtain the number of current parameters
This. getLength = function () {return this. keyValuePairs. length };
// Find the corresponding value based on the input key
This. getValue = function (s ){
Var length = this. getLength ();
For (var I = 0; I <length; I ++ ){
If (this. keyValuePairs [I]. split ("=") [0] = s)
Return this. keyValuePairs [I]. split ("=") [1];
}
};
// Obtain all parameters
This. getParameters = function (){
Var parameters = new Array ();
Var length = this. getLength ();
For (var I = 0; I <length; I ++ ){
Parameters. push (this. keyValuePairs [I]. split ("=") [0]);
}
Return parameters;
}
}
Function analysisUrl (){
// Can be obtained using this. location. search? Parameters
// Alert (this. location. search );
Var page = new PageQuery ("? Userid = 234 & username = sdfsd ");
// Alert (page. getLength ());
Alert (page. getValue ("username "));
Var params = page. getParameters ();
For (var I = 0; I <params. length; I ++ ){
Alert (params [I]);
}
}
</Script>
The above example shows that this category is usable.