Obtaining query parameters in Javascript
Par Goulven le jeudi 4 octobre 2007, 20:22 - Blog - Lien permanent
The location object suffers from poor design in Javascript. Here's a function to retrieve the query parameters from the page (if any).
function getQuery(){
var s = location.search;
var params=Array();
if ( s.length > 0 ) {
s=s.split('?');
s=s[1];
s=s.split('&');
for(i=0;i<s.length;i++){
params.push( s[i].split('=') );
}
}
return params;
}
Enjoy, and if you find anything to add or remove, don't hesitate to let me know in the comments!


Commentaires
Once again, this entry was hard to get through the door, because of escaping less than entities... I had to edit it from the database!
This is what I use :
http://adamv.com/dev/javascript/fil...