MayoorPatel
asked on
Grabbing the Querysting of a URL in Javascript
Hi there I have a javascript call to a reload on my page.
<script type="text/javascript">
parent.location.reload("fi nish.asp?U serId=")
</script>
I need to append finish.asp in the code above with the UserId from the previous page. I am passing the userId in the URL like this
Response.Redirect("finish3 .asp?ID=" & intNewId)
Can anyone help please?
<script type="text/javascript">
parent.location.reload("fi
</script>
I need to append finish.asp in the code above with the UserId from the previous page. I am passing the userId in the URL like this
Response.Redirect("finish3
Can anyone help please?
I've just put together this very basic script - you just need to pass the Querystring parameter name you want to find the value for to the QueryString function, and it will return the value
function QueryString(item) {
// Get the value of the key/value pair in the document URL
var href = window.location.search;
if (href == "") {
return null;
}
href = href.substring(1);
var items = href.split("&");
for (var i = 0; i < items.length; i++) {
var keyValue = items[i].split("=");
if (keyValue[0] == item) {
return keyValue[1];
}
}
return null;
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
http://andrewu.co.uk/tools