Answers for "Get Theme from URL Parameter and enable CSS theme"

1

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!");
Posted by: Guest on May-04-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language