Created
December 24, 2015 18:57
-
-
Save theWill/dbf72174486a5ca9a809 to your computer and use it in GitHub Desktop.
detect salesforce lightning experience - add stylesheet dynamically
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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