PDA

View Full Version : Running execCommand on editable div?


MagSafe
2008-09-02, 15:12
Hi all,

Is there a way to run an execCommand on an editable div?

The iFrame way of doing it is:

document.getElementById("myiframe").contentWindow.document.execCommand();

... but I can't figure out the correct way of doing the same thing on a div :confused:

Thanks for any help :)

chucker
2008-09-02, 15:45
I don't see anything in your code that would be iframe-specific. Just create a div with an id of "myiframe", and it'll work.

MagSafe
2008-09-02, 16:18
I don't see anything in your code that would be iframe-specific. Just create a div with an id of "myiframe", and it'll work.

that's what I thought ... but I get the error (in FF3): document.getElementById("myiframe").contentWindow is undefined

the div looks like:

<div id="page" unselectable="off" contenteditable="true"></div>

chucker
2008-09-02, 16:33
Well, you naturally want to use document.getElementById("page").contentWindow to match your markup.

MagSafe
2008-09-02, 16:42
Well, you naturally want to use document.getElementById("page").contentWindow to match your markup.

oops :p forgot to change the example, it still isn't working though :\