0

I am trying to change the page theme using javascript dynamically and passing the URL of the style sheet. whenever I refresh the page, reload the page, go back etc. It changes back to the default css

  • maybe this one helps [Stack Javascript: Change CSS File Dynamically + Cookie](https://stackoverflow.com/questions/12229413/javascript-change-css-file-dynamically-cookie) – SteelNation Mar 22 '19 at 09:00
  • function changeStyle(cssFile, cssLinkIndex) { var oldlink = document.getElementsByTagName("link").item(cssLinkIndex); var newlink = document.createElement("link"); newlink.setAttribute("rel", "stylesheet"); newlink.setAttribute("type", "text/css"); newlink.setAttribute("href", cssFile); document.getElementsByTagName("head").item(0).replaceChild(newlink, oldlink) } – srinivasan Mar 22 '19 at 09:09
  • I am passing the css url in the button – srinivasan Mar 22 '19 at 09:09

0 Answers0