Get query string from javascript
By using the below code we can get the query string value & we can pass it to new URL.
var QuerystringID = getParameterByName("ID");
if(QuerystringID != "")
{
window.location = "<NewUrl>?DID="+ QuerystringID ;
}
//below function get the query string value from URL
function getParameterByName(name)
{
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
results = regex.exec(location.search);
return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}
var QuerystringID = getParameterByName("ID");
if(QuerystringID != "")
{
window.location = "<NewUrl>?DID="+ QuerystringID ;
}
//below function get the query string value from URL
function getParameterByName(name)
{
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
results = regex.exec(location.search);
return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}
Comments
Post a Comment