Monday, November 15, 2010

Getting Query parameters using Javascript

<script language='JavaScript'>
// get the current URL
var url = window.location.toString();
//get the parameters
var params = RegExp.$1;
// split up the query string and store in an
// associative array
var params = params.split("&");
var queryStringList = {};

for(var i=0;i {
var tmp = params[i].split("=");
queryStringList[tmp[0]] = unescape(tmp[1]);

// print all querystring in key value pairs
for(var i in queryStringList)
document.write(i+" = "+queryStringList[i]+"<br/>");

No comments:

Post a Comment