PageSourceSearch

https://www.highcharts.com/blog/wp-content/themes/wordpress-theme-…/assets/js/iframe-color-scheme.js

js highcharts.com collected 2026-09-24 07:28:34 UTC 955 bytes, 27 lines download raw bytes

1// Sets color-scheme on all iframes according to data-theme on <body>
2function setIframeColorScheme() {
3  const theme = document.body.getAttribute('data-theme') === 'dark' ? 'dark' : 'light';
4  document.querySelectorAll('iframe').forEach(iframe => {
5    try {
6      const doc = iframe.contentWindow.document;
7      if (doc && doc.documentElement) {
8        doc.documentElement.style.colorScheme = theme;
9      }
10    } catch (e) {
11      // Cross-origin iframes cannot be styled
12    }
13  });
14}
15
16window.addEventListener('DOMContentLoaded', setIframeColorScheme);
17
18// Listen for theme changes (MutationObserver)
19const observer = new MutationObserver(setIframeColorScheme);
20observer.observe(document.body, { attributes: true, attributeFilter: ['data-theme'] });
21
22// Optional: also run on iframe load (for dynamically added iframes)
23document.addEventListener('load', function(e) {
24  if (e.target.tagName === 'IFRAME') {
25    setIframeColorScheme();
26  }
27}, true);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.