Closed keanuplayz closed 4 years ago
It may be because you use it without a localserver it may happen if you open directly the html file.
I am using a local server to preview my files.
Do you have any extension blockcking things ? please try with another browser maybe.
Hi, Sandoche. I am facing the same problem. I put the snippet in the head tag of the master page in ASP.Net and it doesn't work. The error is the same as the one above on both Chrome and Edge.
darkmode-js.min.js:1 Uncaught TypeError: Cannot read property 'classList' of null at new e (darkmode-js.min.js:1)
I think the reason this is happening, is because the script attempts to append a DOM object before the DOM tree has loaded. You'll need to call showWidget() after the page has loaded - you can do that by putting it inside an event listener for "load". I made a PR to update the readme as such - see here for details: https://github.com/sandoche/Darkmode.js/pull/47/files
That indeed managed to fix my issue a couple of days back. (see here) I believe this can finally be closed now that we have a definite fix.
For my own website, I decided to give this a shot.
I added the snippet that was given to me to my own page:
But to my surprise, nothing happened.
I checked the console, and found this:
I haven't done anything weird.
I even created a new html document with nothing in it except a default template with some text, added the snippet, and nothing happened.
Any help?