# 如何在嵌入式Discourse中切换暗模式和亮白色模式

**URL:** https://meta.discourse.org/t/how-to-switch-between-dark-mode-and-bright-white-mode-in-embedded-discourse/249542
**Category:** Support
**Created:** [2022年十二月21日 01:06 UTC](https://meta.discourse.org/t/how-to-switch-between-dark-mode-and-bright-white-mode-in-embedded-discourse/249542 "2022-12-21T01:06:22Z")
**Posts on this page:** 1
**Showing post:** 8

<div class="post-metadata">

### Author: ![mikeguo](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mikeguo/32/278830_2.png) [@mikeguo](https://meta.discourse.org/u/mikeguo)
#### Post date: [2023年二月9日 09:45 UTC](https://meta.discourse.org/t/how-to-switch-between-dark-mode-and-bright-white-mode-in-embedded-discourse/249542/8 "2023-02-09T09:45:10Z")

</div>

我使用了官方的最新功能，并已成功实现。  
如果您仍有其他需求，可以参考：

> [@Automatic dark mode for embedded comments as well?](https://meta.discourse.org/t/automatic-dark-mode-for-embedded-comments-as-well/184347/10?u=mikeguo):
>
> I have implemented it by using postMessage. The codes and its execution logic are as blow: Code block ① adds an event listener in embedded Discourse iframe which will post message to my website that contains embedded Discourse iframe once embedded Discourse is loaded. When my website receives message from embedded Discourse, it will make a validation, as shown in code block ②, and if passed, call the setIframeStyle function to set embedded Discourse. The setIframeStyle function, ju…

---

_[View the full topic](https://meta.discourse.org/t/how-to-switch-between-dark-mode-and-bright-white-mode-in-embedded-discourse/249542)._
