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, " "));
}

Comments

Popular posts from this blog

Add content type to SharePoint List/Library using REST API

Upload Single/Multiple file by using the REST API and jQuery SharePoint 2013

A type named 'SP.Data. could not be resolved by the model error