I have a stylepage which should allow the user to change the style of not just the webpage but the whole website. To do this I was planning on inserting rules to my main stylesheet whenever the user selects a property. I have props to call my stylesheet by its id and then insert the rule. Anyone has an idea how to go about it? My stylesheets id is myStylesheet... To be complete I don't want to change my stylesheet or add a new one. If you do that it only works on that one page, I want my whole site to be changed. The function in javascript should look something like this:
funcion bg1 {
var sheet = document.styleSheets[myStylesheet];
sheet.insertRule(
"body{ background-image: url(../afbeeldingen/bg1.jpg);
background-position: center;
background-repeat: repeat;
background-size:100%;}"
;}
but I can't get it to work
funcion bg1{ var sheet = document.styleSheets[myStylesheet]; sheet.insertRule("body{ background-image: url(../afbeeldingen/bg1.jpg);background-position: center; background-repeat: repeat; background-size:100%;}"; }
– ufotje Jan 28 '17 at 16:01but I can't get it to work...