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 =;
//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_;
return qs[1];


Popular posts from this blog

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