前言前端
_spPageContextInfo對象,是SharePoint開發一個很是經常使用的對象,尤爲是前端開發,能夠很是方便的獲取到一些和站點有關的信息。web
完整對象以下圖,須要什麼屬性,能夠本身獲取,而後在代碼中使用了。網站
_spPageContextInfo { [functions]: , alertsEnabled: false, allowSilverlightPrompt: "True", clientServerTimeDelta: -447, crossDomainPhotosEnabled: false, currentCultureName: "en-US", currentLanguage: 2052, currentUICultureName: "zh-CN", isAppWeb: false, isSiteAdmin: true, layoutsUrl: "_layouts/15", pageItemId: 1, pageListId: "{20b11cdc-7008-4c2f-89d6-d7c2ad57cca0}", pagePersonalizationScope: 1, ProfileUrl: "http://moss:80/my/Person.aspx", serverRequestPath: "/SitePages/主頁.aspx", siteAbsoluteUrl: "http://moss", siteClientTag: "13$$16.0.4327.1000", siteServerRelativeUrl: "/", systemUserKey: "S-1-0-0", tenantAppVersion: "0", updateFormDigestPageLoaded: [date] Fri Feb 1 15: 59: 00 UTC + 0800 2019, userId: 1073741823, userLoginName: "SHAREPOINT\system", webAbsoluteUrl: "http://moss", webLanguage: 2052, webLogoUrl: "_layouts/15/images/siteicon.png", webPermMasks: {}, webServerRelativeUrl: "/", webTemplate: "1", webTitle: "開發網站", webUIVersion: 15 }
獲取的截圖以下圖:spa
若是想在JavaScript或者JQuery裏使用的話,直接以下方法使用就能夠了;code
固然,像userLoginName/webAbsoluteUrl/webLangeuage等屬性,是常常會用到的;orm
var siteUrl = _spPageContextInfo.webAbsoluteUrl;
結束語server
SharePoint會爲們提供不少相似的方法,咱們能夠慢慢總結,以便咱們開發中更加快速和方便。對象