Search code examples
javascriptinternet-explorer-8internet-explorer-7contenteditable

contenteditable change event in IE 7 and 8


Just like this other question, I want to be able to call a function when the user changes the contents of a contenteditable DIV. However, I want to support IE 7-10. IE 7 and 8 do not support the 'input' event. IE 9 in Standards mode and IE 10 support 'input', but fail to fire the 'input' event in response to cut, paste, delete (from the context menu), or text-drop operations. In addition, IE 10 on Windows 8 does not fire an 'input' event in response to a spelling correction change when the user selects a suggested spelling from the context menu.

See http://fiddle.jshell.net/2ScfA/show/

In all versions of Internet Explorer, I see 'cut' and 'paste' events when using the Cut and Paste context menu options.

In IE 9 Standards mode and IE 10, I can use DOMNodeRemoved and DOMNodeInserted to handle the changes resulting from dropping text into the contenteditable DIV or using the context menu to change the DIV's contents.

However, IE 7 and 8 do not support the DOM mutation events. If I use IE 7 or 8's Delete or Undo context menu options or drop text into the DIV, I am not seeing an event fired for those changes.

Is there an event that is fired in IE 7 and 8 when the user selects Delete or Undo from the context menu, or drops text into the DIV, and the contenteditable DIV's contents are changed?


Solution

  • onselectionchange is a very useful event in IEs. It is fired on quite similar conditions as oninput in newer browsers.