# כיצד לעבור בין מצב כהה למצב בהיר ב-Discourse משובץ

**URL:** <https://meta.discourse.org/t/how-to-switch-between-dark-mode-and-bright-white-mode-in-embedded-discourse/249542>\
**Category:** Product Support\
**Created:** [21 בדצמבר,‏ 2022,‏ 1:06am 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:** 1

<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:** [21 בדצמבר,‏ 2022,‏ 1:06am UTC](https://meta.discourse.org/t/how-to-switch-between-dark-mode-and-bright-white-mode-in-embedded-discourse/249542/1 "2022-12-21T01:06:22Z")

</div>

My website provides the dark mode button, so when button was click, I need to change the color theme of Dicourse Embeds to keep the same with my website.

But when I try to add class for body of embedded iframe, I found `iframe.contentDocument` is always null, and if use `document.getElementById("discourse-embed-frame").contentWindow.document` , the error as below:

 ![image](https://global.discourse-cdn.com/meta/original/4X/2/9/6/29624779203163f7d0555ca566bd2618a9d2548e.png)

I think there should be a way to config the embedded frame to allow cross-origin, but I still not found how to config after trying some config.

The other way maybe to use `postMessage`, like `document.getElementById("discourse-embed-frame").contentWindow.postMessage("darkMode")`, but there needs to be an handler to handle the `darkMode` message in script, I haven’t found where to add it.

---

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