execCommand Trouble

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Nicodemas
    Recognized Expert New Member
    • Nov 2007
    • 164

    #1

    execCommand Trouble

    (Let's get this out of the way -- I am not a JavaScript expert.)

    I am toying with a rich text editor of my own. It's just for experimentation .

    I have a DIV with contentEditable =true.

    I tried writing a script like the following:

    Code:
    var contentEditZone = document.getElementById('rte') // the DIV with contentEditable=true
    contentEditZone.execCommand("InsertImage", true);
    However, I get the "object does not support this property or method" error in I.E.

    If I read the documentation correctly, this should work. Is it an I.E. bug I am not aware of?
  • phvfl
    Recognized Expert New Member
    • Aug 2007
    • 173

    #2
    Have you tried passing the path to the image as the third arguement? I have also read that calling focus on the editable control resolves some issues on IE8. For example
    Code:
      var contentEditZone = document.getElementById('rte'); // the DIV with contentEditable=true
     contentEditZone.focus();
     contentEditZone.execCommand("InsertImage", true, imagePath);

    Comment

    Working...