# 如何即时切换主题？

**URL:** <https://meta.discourse.org/t/how-to-change-theme-on-the-fly/108342>\
**Category:** Development\
**Created:** [2019 年2 月 4 日 20:51 UTC](https://meta.discourse.org/t/how-to-change-theme-on-the-fly/108342 "2019-02-04T20:51:57Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

作者： ![ggurbet](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ggurbet/32/120188_2.png) [@ggurbet](https://meta.discourse.org/u/ggurbet)\
发布日期： [2019 年2 月 4 日 20:51 UTC](https://meta.discourse.org/t/how-to-change-theme-on-the-fly/108342/1 "2019-02-04T20:51:57Z")

</div>

Hi. I am trying to figure out how to change the theme on the fly as under User → Preferences → Interface → Theme.

 ![image](https://global.discourse-cdn.com/meta/original/3X/5/9/59820a2b84da848cdc8c8629d5a3d8335f115a76.png)  
When you choose a theme from this dropdown box you can see the effect immediately. I want to have this behavior on some links but I don’t know how to do it. I tried looking at Sam’s [Hamburger Theme Selector](https://meta.discourse.org/t/hamburger-theme-selector/61210) but I did not figure out how he did it, since I do not know JavaScript that much. Is there a way to do this? My final goal is to assign this events to a button to toggle between two different themes, which are designed to be day and night themes. Sam’s solution refreshes the page but the already present solution in the User Preferences page is what I am looking for.

---

_[View the full topic](https://meta.discourse.org/t/how-to-change-theme-on-the-fly/108342)._
