Hi while searching for the same,
got the following javascript
q = location.search;
getParam = function(arg) {
if (q.indexOf(arg) >= 0) {
var pntr = q.indexOf(arg) + arg.length + 1;
if (q.indexOf(‘&’, pntr) >= 0) {
return q.substring(pntr, q.indexOf(‘&’, pntr));
} else {
return q.substring(pntr, q.length);
}
} else {
return null;
}
}
var objectId = getParam(‘oId’);
alert(objectId);
or better
function querySt(ji) {
hu = window.location.search.substring(1);
gy = hu.split(“&”);
for (i=0;i<gy.length;i++) {
ft = gy[i].split(“=”);
if (ft[0] == ji) {
return ft[1];
}
}
}
var pId= querySt(“pId”);
alert(pId);
Here oId is the query string parameter whose value we need.
This works even if there are multiple query string parameters !
Bye…
You may be interested in my example using regex.
http://blog.pattenaude.net/2009/06/javascript-to-get-query-params.html
LikeLike
Sorry not trying to spam, but I’m messing with my blog and broke the link… Here’s the code:
var str=”http://www.google.com?q=blah&vv=ha&test&nah=yeah”; // window.location.href
var regex = /[?&]([^=&]*)(?:=([^&]*))?/g;
var res, params = {};
while ((res = regex.exec(str)) != null)
{
params[res[1]] = res[2] || “n/a”;
}
for (a in params)
{
document.write(a + “=” + params[a] + “”);
}
LikeLike
Thanks for that Jerry !!
LikeLike
Third, the famous often fall short of desirable moral and aesthetic standards. ,
LikeLike