Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS How to Change Meta theme dynamically with css?

  • This topic is empty.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #242575
    shmshd12
    Participant

    Is it possible to change meta theme dynamically with css ? My plan is to change meta theme according to user selection of theme and ask user to refresh the page for changes to affect. CSS will be cached in users device.

    #242580
    I.m.learning
    Participant

    You could do a few things; one could be creating a dynamic CSS, another would be creating multiple style sheets

    http://www.thesitewizard.com/javascripts/change-style-sheets.shtml

    #242581
    shmshd12
    Participant

    Thanks for the answer.

    My question is regarding META theme color, which is <meta name=”theme-color” content=”#colorhex”>

    So I need to change the content of meta theme dynamically. Is it possible?

    #242582
    I.m.learning
    Participant

    I never heard of anyone doing this. I would expect the same result; unfortunately, I am using an ancient smartphone that limits testing and does not allow mw to view a lot of what newer phones could view.

    What have you tried?

    I have changed my meta tags through php; adding colors as a variable and placing those variables in a dynamic style sheet, and then using onclick for the options in the html seems like a logical choice.

    Can you change the colors as is? If you can, then you should be able to. I could do some web searches, but without being able to test, I wouldn’t know if it works. Just by searching what you’re asking brings up a lot of people asking to change the color for themselves.

    Now, I did just happen to find this https://html.spec.whatwg.org/multipage/semantics.html#meta-theme-color

    #242595
    Beverleyh
    Participant

    You could change the meta tag colour value with PHP. Here’s a blog/tutorial I wrote a couple of years ago to change a stylesheet based on user selection, and then save that selection for X days in a cookie, but you could adapt it to echo out a hexadecimal colour (in the stored variable) instead of the actual CSS file name: http://www.dynamicdrive.com/forums/entry.php?305-PHP-Stylesheet-Content-Switcher-with-Save-Cookie

Viewing 5 posts - 1 through 5 (of 5 total)
  • The forum ‘CSS’ is closed to new topics and replies.