JSRequest is a utility class providing methods for extracting URL information, including:

  • JSRequest.FileName
  • JSRequest.PathName
  • JSRequest.QueryString["param1"]

It is defined in INIT.JS.  In SharePoint 2010, you can find INIT.JS here (by default):

C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS\1033

This library, along with CORE.JS, CONTROLS.CSS and CORE.CSS support client side functionality.  INIT.JS is not specifically referenced in SharePoint 2010 master pages, but appears to be introduced through this script link statement in default.master:

<SharePoint:ScriptLink language="javascript" name="core.js" defer="true" runat="server"/>

When this is rendered, you will see this in the web page source:

document.write('<script type="text/javascript" src="/_layouts/1033/init.js?rev=BJDmyeIV5jS04CPkRq4Ldg%3D%3D"></' + 'script>');

If you remove the CORE.JS scriptlink, INIT.JS is also affected.  A search through CORE.JS will not find any reference to INIT.JS.

Initializing JSRequest

To use the JSRequest class, you must first initialize it using this method:


Then you can use class methods.

Using JSRequest Methods

JSRequest has three methods that you can use:

JSRequest.FileName: returns just the web page file name.

JSRequest.PathName: returns the relative path.  For example, if the page URL was, it would return: /Northwind/SitePages/MyPage.aspx

 JSRequest.QueryString["MyParam"]: returns the value of the indicated querystring parameter if it exists.  Returns undefined otherwise.