JavaScript is becoming more and more popular as a language for SharePoint solutions. Time to get familiar with the built-in JavaScript repository. I have seen quite of different ways to retrieve querystring parameter values in JavaScript, but SharePoint features it’s own function ‘_spGetQueryParam(p)’.
The function ‘_spGetQueryParam(p)’ is loaded from the ‘init.js’:
function _spGetQueryParam(p)
{ULSA13:;
var q=window.location.search.substring(1);
if(q && q.length > 2)
{
var params=q.split("&");
var l=params.length;
for (var i=0;i<l;i++)
{
var pair=params[i].split("=");
if (pair[0].toLowerCase()==p)
return pair[1];
}
}
}
You need to provide the lowercase name of the parameter to retrieve the value; e.g.:
var currentFolder = _spGetQueryParam('rootfolder')