Skip to content

Instantly share code, notes, and snippets.

@anasnakawa
Last active April 10, 2018 15:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anasnakawa/daa6b671e954882b7982545a5aec8f91 to your computer and use it in GitHub Desktop.
Save anasnakawa/daa6b671e954882b7982545a5aec8f91 to your computer and use it in GitHub Desktop.
hiding side navigation box on SharePoint root site homepage
/* only on root site homepage, hide the side nav box */
[data-root-home=true] #sideNavBox {
display: none !important;
}
// you might want to wait until dom is ready before executing this code
_spPageContextInfo.isWebWelcomePage; // true if homepage of root site or a subsite
_spPageContextInfo.siteServerRelativeUrl === _spPageContextInfo.webServerRelativeUrl; // true means we're on a root site, false on a subsite
// so, we're on a homepage that could be for root site or a subsite
if( _spPageContextInfo.isWebWelcomePage ) {
if( _spPageContextInfo.siteServerRelativeUrl === _spPageContextInfo.webServerRelativeUrl ) {
// homepage of a root site
// add attribute to `html` element, so we can utilize it from css
document.documentElement.setAttribute('data-root-home', true);
} else {
// homepage of a sub site
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment