SharePoint 页面JS上下文对象 "_spPageContextInfo"
来源:互联网 发布:美国农业部数据网站 编辑:程序博客网 时间:2024/05/01 17:42
SharePoint在2010和2013的版本中,注册了一个jS对象“_spPageContextInfo”,在浏览器(Chrome或者IE)中打开SharePoint站点,按F12,在调试控制台中直接输入“_spPageContextInfo”,注意区分大小写,可以列出这个对象包含的一些属性,都是很有用的属性。
在SharePoint 2010的环境中是(使用IE浏览器的截图):
在SharePoint 2013的环境中添加了几个属性(使用Chrome浏览器的截图):
这些属性是很方便使用的,例如获取当前用户的id,当前站点使用的语言,culture,url等等。
查阅一下reflector,可以知道这个对象是通过SharePointClientJs_Register方法注册进来的:
从代码可以看到各个属性对应的具体的值是如何取得的(以SharePoint 2013为例):
其中:
web = SPContext.Current.Web
site = SPContext.Current.Site
alertEnabledsite.WebApplicaiton.AlertsEnabled && site.WebApplication.IsEmailServerSetallowSilverlightPromptsite.WebApplication.AllowSilverlightPromptclientServerTimeDeltanew Date(DateTime.UtcNow.ToString("o", CultureInfor.InvariantCulture))crossDomainPhotosEnabledsite.WebApplication.CrossDomainPhotosEnabledcurrentCultureNameThread.CurrentThread.CurrentCulture.NamecurrentLanguageThread.CurrentThread.CurrentUICulture.LCIDcurrentUICultureNameThread.CurrentThread.CurrentUICulture.NamelayoutsUrlSPHttpUtility.EcmaScriptStringLiteralEncoded(HttpContextLayoutsFolder)pagePersonalizationScopeweb.WebPartManager不为null: web.WebPartManager.Scope否则:wePersonalizationScope.SharedserverRequestPathSPHttpUtility.EcmaScriptStringLiteralEncode(HttpContext.Current.Request.Path)siteAbsoluteUrlSPHttpUtility.EcmaScriptStringLiteralEncode(web.Site.Url)siteClientTagweb.SiteClientTag.ToString(CultureInfo.InvariantCulture)siteServerRelativeUrlSPHttpUtility.EcmaScriptStringLiteralEncode(site.ServerRelativeUrl)systemUserKeySPHttpUtility.EcmaScriptStringLiteralEncode(web.CurrentUser.SystemUserKey)tenantAppVersionSPHttpUtility.EcmaScriptStringLiteralEncode(SPTenantAppUtils.GetTenantAppEtag(web))userIdweb.CurrentUser.ID.ToString(CultureInfo.InvariantCulture)webAbsoluteUrlSPHttpUtility.EcmaScriptStringLiteralEncode(web.Url)webLanguageweb.LanguagewebLogoUrlscriptLiteralToEncode = string.IsNullOrEmpty(web.SiteLogoUrl) ? (SPUtility.GetLayoutsFolder(web) + "/images/siteicon.png") : web.SiteLogoUrl;
SPHttpUtility.EcmaScriptStringLiteralEncode(scriptLiteralToEncode)webServerRelativeUrlSPHttpUtility.EcmaScriptStringLiteralEncode(web.ServerRelativeUrl)webTemplate如果有open的权限:
SPHttpUtility.EcmaScriptStringLiteralEncode(web.WebTemplateId.ToString(CultureInfo.InvariantCulture))
否则是空值webTitle如果有open的权限:SPHttpUtility.EcmaScriptStringLiteralEncode(web.Title) 否则是空值webUIVersionweb.UIVersion.ToString(CultureInfo.InvariantCulture)webPermMasksSPUtility.BasePermissionsToJson(web.EffectiveBasePermissions)
0 0
- SharePoint 页面JS上下文对象 "_spPageContextInfo"
- 通过脚本_spPageContextInfo获取当前SharePoint上下文信息
- JS执行上下文与变量对象
- js页面对象控制
- 页面事务处理 ContextUtil.SetComplete(); 没有 MTS 对象上下文
- HTML页面使用js获取项目上下文路径
- HTML页面使用js获取项目上下文路径
- JS 中 this上下文对象的使用方式
- Sharepoint JS 获取Choice到页面Html的select选项。
- js对象for生成页面
- sharepoint 安装完成后,管理中心老是报js对象不存在
- 不同页面之间传值除了Cookie,Session之外,还可以使用页面的上下文对象
- JSP页面上下文注意
- javascript--上下文对象
- 语言特性-上下文对象
- Android上下文对象Context
- ServletContext上下文对象
- JavaScript上下文执行对象
- pipe row 的用法,Oracle split 函数写法
- scikit-learn的安装
- Maven 手动添加 JAR 包到本地仓库
- linux关机
- cowboy 分析
- SharePoint 页面JS上下文对象 "_spPageContextInfo"
- ACM(011)奇偶数分离(1)
- 陌陌该怎样卸下约炮神器的“美誉”?
- 自定义AlertView(iOS7)
- Linux下获得本机IP
- CSDN 报数游戏-双向循环链表实现
- MSSQL使用OpenRowSet函数导入EXCEL数据
- Web应用程序与桌面应用程序的区别
- debug 64bit dump of a 32bit process in windows 7 64bit