Adding dark mode to my Neocities frameset site

Unfortunately it does not say which error message. Does it matter where in the theme.js I put that function?

Adding double quotation marks to the outside of the parentheses and an equal sign i.e. setThemeColorForAllFrames="('dark')" seems to make the error message go away.

You need to edit your onClick attribute on the buttons.

This is how the light button should look like:

<button onclick="setThemeColorForAllFrames('light')" class="button">Light</button>

And the dark button:

<button onclick="setThemeColorForAllFrames('dark')" class="button">Dark</button>

No, it can be anywhere in the theme.js file. Just put it at the end.

1 Like

Oh my god, I feel so silly. No more error message now! It works wonderfully, thank you again :smiling_face:

Awesome! :partying_face:

I just spotted a typo in my code. In the function setThemeColorForAllFrames() the last line, it should say buttons instead of button:

window.top.document.getElementById('buttons').contentWindow.setColorTheme(theme);

That’s why the bottom right frame is not updated on the button click right now.

1 Like

Thanks for catching this! Now I just have to figure out how to have dark/lightmode background images…