Skip to content

Instantly share code, notes, and snippets.

@NoNamePro0
Last active April 21, 2020 13:49
Show Gist options
  • Save NoNamePro0/90235465714e01b1f1c05b4c0813b592 to your computer and use it in GitHub Desktop.
Save NoNamePro0/90235465714e01b1f1c05b4c0813b592 to your computer and use it in GitHub Desktop.
Get Theme from URL Parameter and enable CSS theme
var head = document.getElementsByTagName('HEAD')[0];
const queryString = window.location.search;
const urlParams = new URLSearchParams(queryString);
const theme = urlParams.get('theme')
var link = document.createElement('link');
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = 'src/css/themes/' + theme + '.css';
head.appendChild(link);
console.log(theme + " theme enabled!");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment