8.12.14

SharePoint - JavaScript current page context info

var _spPageContextInfo = {
   2:     webServerRelativeUrl: "\u002ftest",
   3:     webAbsoluteUrl: "http:\u002f\u002fexample\u002ftest",
   4:     siteAbsoluteUrl: "http:\u002f\u002fexample.com\u002ftest",
   5:     serverRequestPath: "\u002f_layouts\u002f15\u002fosssearchresults.aspx",
   6:     layoutsUrl: "_layouts\u002f15",
   7:     webTitle: "Home",
   8:     webTemplate: "53",
   9:     tenantAppVersion: "0",
  10:     webLogoUrl: "_layouts\u002f15\u002fimages\u002fsiteicon.png",
  11:     webLanguage: 1033,
  12:     currentLanguage: 1033,
  13:     currentUICultureName: "en-US",
  14:     currentCultureName: "en-US",
  15:     clientServerTimeDelta: new Date("2013-06-07T19:07:01.3494510Z") - new Date(),
  16:     siteClientTag: "40$$15.0.4420.1017",
  17:     crossDomainPhotosEnabled: false,
  18:     webUIVersion: 15,
  19:     webPermMasks: {
  20:         High: 2147483647,
  21:         Low: 4294967295
  22:     },
  23:     pagePersonalizationScope: 1,
  24:     userId: 1,
  25:     systemUserKey: "i:0\u0029.w|s-1-5-21-...",
  26:     alertsEnabled: false,
  27:     siteServerRelativeUrl: "\u002ftest",
  28:     allowSilverlightPrompt: 'True'
  29: };

example, open current page's version history:

open content editor web part and past this:

<script>function openModal(){var options = {    tite: "Version History",    url: _spPageContextInfo.webServerRelativeUrl + "/_layouts/Versions.aspx?list="+ _spPageContextInfo.pageListId +"&ID="+ _spPageContextInfo.pageItemId,    width: 800,    height: 500,};SP.UI.ModalDialog.showModalDialog(options);}</script><a href="javascript:openModal()">open</a>




Name
SP2010
SP2013
Example Value
currentLanguage
X
X
1033
pageItemId
X
X
1
pageListId
X
X
Guid
webLanguage
X
X
1033
webServerRelativeUrl
X
X
/
webUIVersion
X
X
4 or 15
alertsEnabled
X
X
False
allowSilverlightPrompt
X
X
False
userId
X
X
9
clientServerTimeDelta

X
Time
crossDomainPhotosEnabled

X
False
currentCultureName

X
en-US
currentUICultureName

X
en-US
layoutsUrl

X
_layouts/15
pagePersonalizationScope

X
1
serverRequestPath

X
/SitePages/Home.aspx
siteAbsoluteUrl

X
http://sp
siteClientTag

X
0$$15.0.4420.1017
siteServerRelativeUrl

X
/
systemUserKey

X
1:0).w|<sid>
tenantAppVersion

X
0
webAbsoluteUrl

X
http://sp
webTemplate

X
1
webLogoUrl

X
_layouts/15/images/siteicon.png
webPermMasks

X
Object with properties
High & Low
webTitle

X
Test
 

No comments:

Post a Comment