Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Introduction
This article is particularly relevant to you if you are creating a SharePoint app using JavaScript and the Client side object model. In the development of such an app, we would require some basic properties- SharePoint provides these with the _spPageContextInfo object.
_*** spPageContextInfo ***will provide these below properties:
- webServerRelativeUrl
- webAbsoluteUrl
- siteAbsoluteUrl
- serverRequestPath
- layoutsUrl
- webTitle
- webTemplate
- tenantAppVersion
- isAppWeb
- webLogoUrl
- webLanguage
- currentLanguage
- currentUICultureName
- currentCultureName
- env
- nid
- fid
- clientServerTimeDelta
- updateFormDigestPageLoaded
- siteClientTag
- crossDomainPhotosEnabled
- webUIVersion
- webPermMasks
- pagePersonalizationScope
- userId
- userLoginName
- systemUserKey
- alertsEnabled
- siteServerRelativeUrl
- allowSilverlightPrompt
- themedCssFolderUrl
- themedImageFileNames
Implementation
You can also access this object in JavaScript model as:
<script type="text/javascript">
var propertyValue = _spPageContextInfo.PropertyName
</script>
Example
Get current login user name
<script type="text/javascript">
var loginName = _spPageContextInfo.userLoginName
alert(loginName)
</script>
The above example will show an alert of value current user login.
To check the properties and its value of _spPageContextInfo, browse a SharePoint web page and open its view source (HTML - right click on web page ? view page source) and find text "spPageContextInfo".
See below screenshot:
http://3.bp.blogspot.com/-mHJ9AfR-u4s/VMiiWUh786I/AAAAAAAAALw/N4R-KO-fcgI/s1600/_spPageContextInfo.png