Trying to add text into an editable div that is in an iframe

Joined
Dec 14, 2021
Messages
28
Reaction score
2
I have an iframe, it links to an HTML file that has a div that can be edited, I am trying to add content to that div, though all that I have tried hasn't worked.

Here is the iframe:
HTML:
<div><div id="testing" contenteditable></div></div>

Ofcourse there is more in the HTML file the iframe displays, but the rest isn't important. So here is the code that I've tried:
JavaScript:
function timpin() {
    var iframe = document.getElementById("textField");
    var elmnt = iframe.contentWindow.document.getElementById("testing");
    elmnt.innerHTML += "timpin ";
}

I do believe that it should work, but it isn't and I can't find out why.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,734
Messages
2,569,441
Members
44,832
Latest member
GlennSmall

Latest Threads

Top