WmZilla - Webmaster and Marketplace

The Next Generation Webmaster and Trade Forum

JavaScript LocalStorage organization

Bizz

New member

0

0%

Status

Offline

Posts

27

Likes

0

Rep

0

Bits

145

3

Months of Service

0%
I have the following code available: And also this javascript code; var swapStyleSheet = function (sheet) { document.getElementById('pagestyle').setAttribute('href', sheet); storebackground(sheet); } var storebackground = function (swapstylesheet) { localStorage.setItem("sheetKey", swapstylesheet); //you need to give a key and value } var loadbackground = function () { document.getElementById('pagestyle').setAttribute('href', localStorage.getItem('sheetKey')); } window.loadbackground(); It works smoothly in the following usage. When the Dark Style Sheet CSS changes, all other codes first display the old CSS and then the new one comes in, but in this case, the new one appears as if it hasn't changed at all. However, the issue is that when I run this code, the site goes themeless until a theme is selected. How can we set this as default, what code should we add?
 

249

6,622

6,642

Top