- This topic is empty.
-
AuthorPosts
-
June 6, 2016 at 4:07 pm #242575
shmshd12
ParticipantIs 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.
June 6, 2016 at 5:33 pm #242580I.m.learning
ParticipantYou 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
June 6, 2016 at 5:38 pm #242581shmshd12
ParticipantThanks 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?
June 6, 2016 at 6:20 pm #242582I.m.learning
ParticipantI 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
June 7, 2016 at 12:09 am #242595Beverleyh
ParticipantYou 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
-
AuthorPosts
- The forum ‘CSS’ is closed to new topics and replies.