_spPageContextInfo,一段非常有用的SharePoint JavaScript代码,通过它可以很方便获取当前页面的相关信息。
Name | SP2007 | SP2010 | SP2013 | Example Value |
---|---|---|---|---|
alertsEnabled | X | X | false | |
allowSilverlightPrompt | X | X | true | |
clientServerTimeDelta | X | 17856 | ||
crossDomainPhotosEnabled | X | true | ||
currentCultureName | X | en-US | ||
currentLanguage | X | X | 1033 | |
currentUICultureName | X | en-US | ||
L_Menu_BaseUrl | X | X | X | /Sites/Demos |
layoutsUrl | X | _layouts/15 | ||
pageItemId | X | X | 1 | |
pageListId | X | X | GUID | |
pagePersonalizationScope | X | 1 | ||
serverRequestPath | X | /Sites/Demos/SitePages/Home.aspx | ||
siteAbsoluteUrl | X | http://sharepoint.com | ||
siteClientTag | X | 21$$15.0.4454.1026 | ||
siteServerRelativeUrl | X | /sites/Demos | ||
systemUserKey | X | 1:0).w|<sid> | ||
tenantAppVersion | X | 0 | ||
userId | X | X | 30 | |
webAbsoluteUrl | X | http://sharepoint.com/sites/demos | ||
webLanguage | X | X | 1033 | |
webLogoUrl | X | _layouts/15/images/siteicon.png | ||
webPermMasks | X | Object with properties High & Low | ||
webServerRelativeUrl | X | X | /Sites/Demos | |
webTemplate | X | 1 | ||
webTitle | X | Demos | ||
webUIVersion | X | X | 4 (2010) or 15 (2013) |
下面是一段简单的代码创建了一个带有图片的超链接,当点击超链接时会跳到当前Site Collection首页
<A onclick="window.location = _spPageContextInfo.siteAbsoluteUrl;">
<IMG class=logo alt="W Logo" src="/_layouts/15/ProjectFeature_7949818d75c64017bf5008b1391486e1/Images/wLogo.png">
</A>