Theme Setter

I wrote a script a few months ago. It needs improvement but I hope it works. See Theme Setter. As I describe in that page, the script uses the HTML5 Web Storage API (not cookies) to store a theme name across sessions without using logins. The CSS for the selected theme is copied to each page browsed, therefore allowing visitors to choose the theme they prefer. Currently the only difference among the themes I have provided is colors.

My main question is, does it work for you? You can test it by clicking the “Click here to change the theme.” link at the top of the pages in the site.

Are there similar scripts available? I could not find something like that when I searched before writing the script.


Sadly, it doesn’t work for me. The first page pops up an alert (urgh) and when I click on the link to change the theme, I get taken to the ThemeSetter page and see two more alerts (more urgh). The select menu on this page is empty, as if it was being populated server-side and the server-side script is failing.

If I then go back to the main page, no styles have been applied/persisted.

This kind of thing?

Thank you for trying it. It is frustrating since it works for me.

There is nothing executed in the server. I don’t know if I can send error information back to the server, I will check into that.

I have changed the alert to a console.log. Does it show an alert now?

There does seem to be problems with ASP.Net that I was not aware of previously and that I don’t understand. I will look at the other script to see if it has any relevant help.

Sorry man, I’m still seeing the same thing.

I don’t like the way that HTML and CSS are designed. There are too many peculiarities and exceptions. I will redesign my script so it is less dependent on the peculiarities of CSS.

Lol, what? It has nothing to do with the particularities of CSS. Let me make sure I understood you correctly. You are trying to let you implement a script that let’s you dynamically change the CSS applied to a page (i.e. change from one theme to the other). Your script should then remember the choice as a user navigates around your site. Did I get that right?

I apologize for using fancy terminology but “peculiarities of CSS” is a fancy way of saying “how CSS works”. Just read some of the detailed specifications of how CSS words; I don’t mean tutorials, I mean the actual full specifications of how CSS works. Just the rules for Link tags for stylesheets are complicated.

Programming for CSS “has nothing to do with the particularities of CSS”? Of course it does. Particularities is another way of saying details, specifications or “how it works”.


So, can I help you with getting this to work on your site?

I have a new version that I think works except I can’t Execute script upon navigating back to a page. Currently I must refresh a page to get a new setting but otherwise I think everything else works. What I am doing now is to use alternate stylesheets.

Well this is interesting. I uploaded the new script and now it does not have the problem of the page not changing. I did not yet update the description in the site very well; I will do that later.

I found Alternative Style Sheets - CSS | MDN and that explains things better than anything I found previously. Using the new script when my site is browsed with Firefox we should be able to use “View” | “Page Style” to switch the style. Oh, I just now realized that if we use Firefox then the change won’t be saved. My script will save the setting whether we use Firefox or any browser that supports local storage.

Update: the new CSS does not work in Chrome. In Firefox I have the problem described previously; I must do a refresh in Firefox. Everything seems to work in Edge.

Out of interest, why would you want to do that? I had to search to even find the “View” option (I had hidden the menu bar ages ago) and it’s way more clicks than a link on the page.

Where do you think I said that the user must do it the way that Firefox does it? I am saying it uses (or is intended to use) CSS in a manner that is technically compatible with Firefox. It uses stylesheets (.css files) and link tags in a manner that is compatible with Firefox and therefore is more likely to be compatible with other software too.

Okay man, well good luck :slight_smile:

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.