The Little JavaScript Gifts from SharePoint

Ever needed to quickly figure out what web application you are in using JavaScript? Or get the site collection URL?

SharePoint has a fantastic somewhat little know JavaScript object declared in the MasterPage.


This object contains a ton of useful contextual information that can be accessed simply by referencing it:

<script type="text/javascript">
var loginName = _spPageContextInfo.userLoginName

There is a fantastic listing of all the different properties here: