In this post, I will explain how to get query string value using ECMA script
<script type="text/ecmascript">
ExecuteOrDelayUntilScriptLoaded(GetValue, "sp.js");
function GetValue()
{
var qs = getQueryStringValue();
var myParam= qs["ID"];
alert(myParam);
}
function getQueryStringValue()
{
var associate = {};
var decodevalue = function (s)
{
return decodeURIComponent(s.replace(/\+/g, " "));
};
var queryString = location.search.substring(1);
var keyValues = queryString.split('&');
for(var sm in keyValues)
{
var key = keyValues[sm].split('=');
if (key.length > 1)
{
associate[decodevalue(key[0])] = decodevalue(key[1]);
}
}
return associate;
}
</script>
<script type="text/ecmascript">
ExecuteOrDelayUntilScriptLoaded(GetValue, "sp.js");
function GetValue()
{
var qs = getQueryStringValue();
var myParam= qs["ID"];
alert(myParam);
}
function getQueryStringValue()
{
var associate = {};
var decodevalue = function (s)
{
return decodeURIComponent(s.replace(/\+/g, " "));
};
var queryString = location.search.substring(1);
var keyValues = queryString.split('&');
for(var sm in keyValues)
{
var key = keyValues[sm].split('=');
if (key.length > 1)
{
associate[decodevalue(key[0])] = decodevalue(key[1]);
}
}
return associate;
}
</script>
No comments:
Post a Comment