Just little about C#, .NET, SQL Server, SharePoint and SAP

Reading QueryString paramater values using JavaScript in SharePoint

Posted by zieglers on November 13, 2009

Here is a nice javascript snippet which allows you to read querystring parameter values. Actually i used this code in a SharePoint application page to read ListId and ItemId values that i was passing from previous page.

// ************************************************************
// Create an array to keep query string variables
var qsParm = new Array();
// This function gets query string values from current page
// and stores them in above defined array
function qs()
            var query = window.location.search.substring(1);
            var parms = query.split(‘&’);
            for (var i=0; i<parms.length; i++) {
                var pos = parms[i].indexOf(‘=’);
                if (pos > 0)
                    var key = parms[i].substring(0,pos);
                    var val = parms[i].substring(pos+1);
                    qsParm[key] = val;

qsParm[‘ListId’] = null;
qsParm[‘ItemId’] = null;
// Call function – get query strings
// For example show ListId
// ************************************************************


Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: