Skip to content Skip to sidebar Skip to footer

Force Browser To Insert

Tag When Pressing Enter In A Designmode Iframe

How can I make the browser insert

tags instead of tags when I press enter in a designMode IFrame? I get inconsistent behavior across Firefox, Chrome and IE and

Solution 1:

It seems you can't. Behaviour is not standardized and control for this is rudimentary at best

This is an interesting thread from May thie year on the matter: http://lists.whatwg.org/htdig.cgi/whatwg-whatwg.org/2011-May/031577.html . It's discussing contenteditable rather than designMode but they're effectively very similar.

An email on the thread ( http://lists.whatwg.org/htdig.cgi/whatwg-whatwg.org/2011-May/031604.html ) from Simon Pieters (zcorpan) of Opera says:

Opera 11.10 has introduced document.execCommand('opera-defaultblock','','div') to switch to using <div>s instead of <p>s. ('p' is also allowed to switch back.) Apparently WebKit considers implementing this as well. https://bugs.webkit.org/show_bug.cgi?id=59961

Further in the thread there's also this email http://lists.whatwg.org/htdig.cgi/whatwg-whatwg.org/2011-May/031685.html by Markus Ernst including this comment:

I assume there are use cases for both generating <p>s and <br>s. The IE/Opera approach has the advantage of allowing both, which is perfect for text and basic HTML editing. From a WYSIWYG POV it might be best to offer both options, so authors are not encouraged to add server-side processing to change the output, which would break WYSIWYG.

If the behavior is settable, it might even be a good idea to leave the choice of the standard behavior to the UAs. Authors who have a reason to care can set their preferred behavior, while other authors might prefer to leave it as it was, so there is no change for their existing users.

There's lots more on the thread about what people at the various browser makers think ought to happen, comments on some very strange existing behaviours, and general discussion about the problem involved in implementing it at all.

The currently very alpha spec for all this is at http://aryeh.name/spec/editing/editing.html

Post a Comment for "Force Browser To Insert

Tag When Pressing Enter In A Designmode Iframe"