Skip to content Skip to sidebar Skip to footer

User Events Related To Contenteditable

I am a beginner in Javascript & HTML5 Suppose I have a contenteditable
[block-level] element in my HTML5 window. What is the exhaustive list of Javascript events wh

Solution 1:

The exhaustive list of events on contenteditable elements is the same as for input type=text. See this list of all events (look especially at Form Events): http://www.w3schools.com/tags/ref_eventattributes.asp

"How should I code in Javascript to reject some user action?"... just put "event.preventDefault()" at the beginning of an event listener for the event of that action. Example to reject keypresses:

contenteditableElement.addEventListener('keypress', function(e) {
    e.preventDefault();
    // do something else, maybe...
});

To undo a user's action:

document.execCommand('undo', false, '');

As to designing rich text editors, there are many good demos available. I recommend: https://developer.mozilla.org/en-US/docs/Rich-Text_Editing_in_Mozillahttp://www.quirksmode.org/dom/execCommand/ Make sure to view source of the last link; especially the buttons.js file. Also check out the amazing commands list on the MDN article. Good luck -- but try not to re-invent the wheel. There are many well-tested editors out there; check out this list: http://www.webdesignerdepot.com/2008/12/20-excellent-free-rich-text-editors/

Post a Comment for "User Events Related To Contenteditable"