L3010
New Member
Posts: 49
inherit
264353
0
Mar 4, 2023 7:57:32 GMT -8
L3010
49
May 2021
l3010
|
Post by L3010 on Sept 17, 2021 0:22:52 GMT -8
Hi!
I'm want to change the background color of the <body>-element inside the <iframe>-tag at Posting Page.
<script> var editorIframe = document.querySelector('div.editor:nth-child(3) > iframe:nth-child(1)') editorIframe.contentWindow.document.head.innerHTML += `<style> * { background-color: orange !important;}</style>`; </script>
document.querySelector('div.editor:nth-child(3) > iframe:nth-child(1)').contentWindow.document.head.innerHTML += `<style> * { background-color: orange !important;}</style>`;
This second code changes the background color of the post to orange when i execute it in the console. The first code doesn't work in the Posting Page layout template, i suspect that it is because of the code being executed before the CSS of the iframe has loaded.
Does anyone have any ideas of a way to change the background color of the post?
Thanks, Leo
|
|
inherit
Official Code Helper
65613
0
1
Oct 22, 2024 1:56:19 GMT -8
Chris
"'Oops' is the sound we make when we improve"
9,018
December 2005
horace
RedBassett's Mini-Profile
|
Post by Chris on Sept 17, 2021 5:57:09 GMT -8
The proprietary Proboards WYSIWYG is built client-side so if you wish to modify it then you should first listen for the jquery-ui custom event wysiwygcreate then do your mods when it is ready to be modified:
$(document).on('wysiwygcreate',function(event){ document.querySelector('div.visual-editor > iframe')... })
ETA: Incidentally if you're from the Grammarly Development team that is the approach you need to take to get your extension working on Proboards' preview tab. The iframe is SAMEORIGIN so accessing content is not an issue.
|
|