Getting the Querystring using Javascripts

The following javascript displays how to get a querystring value from a URL.

function RetreiveValues()
{
//Getting the URL part
var querystring = location.search.substring(1);
//Getting the string value
var objectTypeCode = getQuerystring('Flag');
}


function getQuerystring(key, default_)
{
if (default_ == null) default_ = "";
key = key.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
var regex = new RegExp("[\\?&]" + key + "=([^&#]*)");
var qs = regex.exec(window.location.href);
if (qs == null)
return default_;
else
return qs[1];
}

Comments

Popular posts from this blog

Error message “User does not have send-as privilege.” when sending emails programmatically in CRM 2011