11.03.2024, 12:55
This should work with iframes:
Code:
$(function(){
if (!window.Storage) {
return;
}
var bc = new BroadcastChannel('darkmode');
function get() {
return !!Storage.get('darkmode', '');
}
function set() {
$('body').toggleClass('dark', get());
}
$('.toggle-dark-mode').off('vclick').on('vclick', function() {
Storage.set('darkmode', get() ? '' : 'y');
bc.postMessage('set');
set();
});
bc.addEventListener('message', set);
set();
});