html - Contenteditable paragraph tag on enter -


i wondering if there acceptable way force major browsers insert paragraph tag instead of default tag insert on pressing enter key when contenteditable true.

as far know ie inserts p automatically. google chrome inserts div tag , firefox inserts br (wtf?!).

thanks in advance!

you can use document.execcommand('formatblock', false, 'p'); in event keypress or keydown, etc. use paragraphs after enter press. example:

element.addeventlistener('keypress', function(ev){     if(ev.keycode == '13')         document.execcommand('formatblock', false, 'p'); }, false); 

Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -