Skip to content

Instantly share code, notes, and snippets.

@theWill
Created December 24, 2015 18:57
Show Gist options
  • Save theWill/dbf72174486a5ca9a809 to your computer and use it in GitHub Desktop.
Save theWill/dbf72174486a5ca9a809 to your computer and use it in GitHub Desktop.
detect salesforce lightning experience - add stylesheet dynamically
if( isLightningExperienceOrSalesforce1() ) {
//add the lightning stylesheet to the header
link = document.createElement( "link" );
link.href = "{!URLFOR($Resource.SLDS0121, 'assets/styles/salesforce-lightning-design-system-vf.css')}"
link.type = "text/css";
link.rel = "stylesheet";
link.media = "all";
document.getElementsByTagName("head")[0].appendChild(link);
}
else {
// Use classic Visualforce
}
function isLightningExperienceOrSalesforce1() {
return((typeof sforce != 'undefined') && sforce && (!!sforce.one));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment