WYSIWYG iframe editor and oninput event.

Posted by teehoo on Stack Overflow See other posts from Stack Overflow or by teehoo
Published on 2010-04-26T14:18:28Z Indexed on 2010/04/26 14:23 UTC
Read the original article Hit count: 323

Filed under:
|
|
|

I'm writing a simple WYSIWYG editor in an iframe, but having trouble registering the "oninput" event to detect when the user modifies the text field such as pasting in data etc.

    var txtArea = document.getElementById('txtArea');       
    txtArea.contentWindow.document.designMode="on";
    txtArea.contentWindow.document.open();
    txtArea.contentWindow.document.write("<head><style type='text/css'>body{font-size:13px;}</style></head><body>"+data.document+"</body>");
    txtArea.contentWindow.document.close();

    $([txtArea.contentWindow.document]).bind("click", updateCaretPosMouse); //fires
    $([txtArea.contentWindow.document]).bind("keyup", updateCaretPosKeyboard); //fires
    $([txtArea.contentWindow.document]).bind("input", textChanged); //doesn't fire

If I create a plain old element, and add the "input" event to this, then it works. Do 'input" events not work with iframes WYSIWYG editors?

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about iframe