Weeks ago I needed to get queystring parameters using JavaScript. I found a function called querySt(), this function is quite useful but I added an extra line that returns the string "undefined" in the case that the requested parameter does not exists in the querystring. My final code is:
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];
}
}
return "undefined";
}
No comments:
Post a Comment