{"id":180,"date":"2015-06-05T19:05:26","date_gmt":"2015-06-05T19:05:26","guid":{"rendered":"https:\/\/itgroove.net\/bangimportant\/?p=180"},"modified":"2023-02-24T21:39:43","modified_gmt":"2023-02-24T21:39:43","slug":"the-little-javascript-gifts-from-sharepoint","status":"publish","type":"post","link":"https:\/\/regroove.ca\/archive\/2015\/06\/05\/the-little-javascript-gifts-from-sharepoint\/","title":{"rendered":"The Little JavaScript Gifts from SharePoint"},"content":{"rendered":"\n<p>Ever needed to quickly figure out what web application you are in using JavaScript? Or get the site collection URL?<\/p>\n\n\n\n<p>SharePoint has a fantastic somewhat little know JavaScript object declared in the MasterPage.<\/p>\n\n\n\n<p><strong>_spPageContextInfo<br><\/strong><\/p>\n\n\n\n<p>This object contains a ton of useful contextual information that can be accessed simply by referencing it:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;script type=\"text\/javascript\"&gt;\n<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">var loginName = _spPageContextInfo.userLoginName\n<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">alert(loginName)\n<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;\/script&gt;\n\n<\/pre>\n\n\n\n<p>There is a fantastic listing of all the different properties here: <a href=\"http:\/\/blah.winsmarts.com\/2013-2-_sppagecontextinfo_is_your_new_best_friend.aspx\" target=\"_blank\" rel=\"noreferrer noopener\">http:\/\/blah.winsmarts.com\/2013-2-_sppagecontextinfo_is_your_new_best_friend.aspx<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Ever needed to quickly figure out what web application you are in using JavaScript? Or get the site collection URL? SharePoint has a fantastic somewhat little know JavaScript object declared in the MasterPage. _spPageContextInfo This object contains a ton of useful contextual information that can be accessed simply by referencing it: &lt;script type=&#8221;text\/javascript&#8221;&gt; var loginName &hellip; <a href=\"https:\/\/regroove.ca\/archive\/2015\/06\/05\/the-little-javascript-gifts-from-sharepoint\/\"><\/a><\/p>\n","protected":false},"author":13,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"inline_featured_image":false,"footnotes":""},"categories":[4,7,9],"tags":[],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v23.0 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>The Little JavaScript Gifts from SharePoint - Archive<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/regroove.ca\/archive\/2015\/06\/05\/the-little-javascript-gifts-from-sharepoint\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"The Little JavaScript Gifts from SharePoint - Archive\" \/>\n<meta property=\"og:description\" content=\"Ever needed to quickly figure out what web application you are in using JavaScript? Or get the site collection URL? SharePoint has a fantastic somewhat little know JavaScript object declared in the MasterPage. _spPageContextInfo This object contains a ton of useful contextual information that can be accessed simply by referencing it: &lt;script type=&quot;text\/javascript&quot;&gt; var loginName &hellip;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/regroove.ca\/archive\/2015\/06\/05\/the-little-javascript-gifts-from-sharepoint\/\" \/>\n<meta property=\"og:site_name\" content=\"Archive\" \/>\n<meta property=\"article:published_time\" content=\"2015-06-05T19:05:26+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-02-24T21:39:43+00:00\" \/>\n<meta name=\"author\" content=\"Colin Phillips (Alumni)\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Colin Phillips (Alumni)\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/regroove.ca\/archive\/2015\/06\/05\/the-little-javascript-gifts-from-sharepoint\/\",\"url\":\"https:\/\/regroove.ca\/archive\/2015\/06\/05\/the-little-javascript-gifts-from-sharepoint\/\",\"name\":\"The Little JavaScript Gifts from SharePoint - Archive\",\"isPartOf\":{\"@id\":\"https:\/\/regroove.ca\/archive\/#website\"},\"datePublished\":\"2015-06-05T19:05:26+00:00\",\"dateModified\":\"2023-02-24T21:39:43+00:00\",\"author\":{\"@id\":\"https:\/\/regroove.ca\/archive\/#\/schema\/person\/adeb0df1cc7a862160be620ca7eace1b\"},\"breadcrumb\":{\"@id\":\"https:\/\/regroove.ca\/archive\/2015\/06\/05\/the-little-javascript-gifts-from-sharepoint\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/regroove.ca\/archive\/2015\/06\/05\/the-little-javascript-gifts-from-sharepoint\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/regroove.ca\/archive\/2015\/06\/05\/the-little-javascript-gifts-from-sharepoint\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Blog Archive\",\"item\":\"https:\/\/regroove.ca\/archive\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"The Little JavaScript Gifts from SharePoint\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/regroove.ca\/archive\/#website\",\"url\":\"https:\/\/regroove.ca\/archive\/\",\"name\":\"Archive\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/regroove.ca\/archive\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/regroove.ca\/archive\/#\/schema\/person\/adeb0df1cc7a862160be620ca7eace1b\",\"name\":\"Colin Phillips (Alumni)\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/regroove.ca\/archive\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/14eeab0d377e9630e0983d9c08911979?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/14eeab0d377e9630e0983d9c08911979?s=96&d=mm&r=g\",\"caption\":\"Colin Phillips (Alumni)\"},\"url\":\"https:\/\/regroove.ca\/archive\/author\/cphillips\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"The Little JavaScript Gifts from SharePoint - Archive","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/regroove.ca\/archive\/2015\/06\/05\/the-little-javascript-gifts-from-sharepoint\/","og_locale":"en_US","og_type":"article","og_title":"The Little JavaScript Gifts from SharePoint - Archive","og_description":"Ever needed to quickly figure out what web application you are in using JavaScript? Or get the site collection URL? SharePoint has a fantastic somewhat little know JavaScript object declared in the MasterPage. _spPageContextInfo This object contains a ton of useful contextual information that can be accessed simply by referencing it: &lt;script type=\"text\/javascript\"&gt; var loginName &hellip;","og_url":"https:\/\/regroove.ca\/archive\/2015\/06\/05\/the-little-javascript-gifts-from-sharepoint\/","og_site_name":"Archive","article_published_time":"2015-06-05T19:05:26+00:00","article_modified_time":"2023-02-24T21:39:43+00:00","author":"Colin Phillips (Alumni)","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Colin Phillips (Alumni)"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/regroove.ca\/archive\/2015\/06\/05\/the-little-javascript-gifts-from-sharepoint\/","url":"https:\/\/regroove.ca\/archive\/2015\/06\/05\/the-little-javascript-gifts-from-sharepoint\/","name":"The Little JavaScript Gifts from SharePoint - Archive","isPartOf":{"@id":"https:\/\/regroove.ca\/archive\/#website"},"datePublished":"2015-06-05T19:05:26+00:00","dateModified":"2023-02-24T21:39:43+00:00","author":{"@id":"https:\/\/regroove.ca\/archive\/#\/schema\/person\/adeb0df1cc7a862160be620ca7eace1b"},"breadcrumb":{"@id":"https:\/\/regroove.ca\/archive\/2015\/06\/05\/the-little-javascript-gifts-from-sharepoint\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/regroove.ca\/archive\/2015\/06\/05\/the-little-javascript-gifts-from-sharepoint\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/regroove.ca\/archive\/2015\/06\/05\/the-little-javascript-gifts-from-sharepoint\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog Archive","item":"https:\/\/regroove.ca\/archive\/"},{"@type":"ListItem","position":2,"name":"The Little JavaScript Gifts from SharePoint"}]},{"@type":"WebSite","@id":"https:\/\/regroove.ca\/archive\/#website","url":"https:\/\/regroove.ca\/archive\/","name":"Archive","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/regroove.ca\/archive\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/regroove.ca\/archive\/#\/schema\/person\/adeb0df1cc7a862160be620ca7eace1b","name":"Colin Phillips (Alumni)","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/regroove.ca\/archive\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/14eeab0d377e9630e0983d9c08911979?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/14eeab0d377e9630e0983d9c08911979?s=96&d=mm&r=g","caption":"Colin Phillips (Alumni)"},"url":"https:\/\/regroove.ca\/archive\/author\/cphillips\/"}]}},"_links":{"self":[{"href":"https:\/\/regroove.ca\/archive\/wp-json\/wp\/v2\/posts\/180"}],"collection":[{"href":"https:\/\/regroove.ca\/archive\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/regroove.ca\/archive\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/regroove.ca\/archive\/wp-json\/wp\/v2\/users\/13"}],"replies":[{"embeddable":true,"href":"https:\/\/regroove.ca\/archive\/wp-json\/wp\/v2\/comments?post=180"}],"version-history":[{"count":1,"href":"https:\/\/regroove.ca\/archive\/wp-json\/wp\/v2\/posts\/180\/revisions"}],"predecessor-version":[{"id":1839,"href":"https:\/\/regroove.ca\/archive\/wp-json\/wp\/v2\/posts\/180\/revisions\/1839"}],"wp:attachment":[{"href":"https:\/\/regroove.ca\/archive\/wp-json\/wp\/v2\/media?parent=180"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/regroove.ca\/archive\/wp-json\/wp\/v2\/categories?post=180"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/regroove.ca\/archive\/wp-json\/wp\/v2\/tags?post=180"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}