View Full Version : Exiting <h1> style in designmode

08-07-2008, 01:12 AM
Hey, folks, I've got myself a rich text editor in an Iframe with designmode=on.

everything is fine. So then I go and make a "headline" style button using something like this:


ok, good. It formats the selection in <h1>. except it is now difficult (or even impossible) to leave the h1 tag.

You can't just (formatBlock , h1) it back off the way you can add and remove italics or bold or something. In FF the only way to exit the style is to press return a few times and retype. in Safari, that doesn't even work - if you add the headline style to the entire body, it actually becomes impossible to exit headline. RemoveFormatting doesn't really work either.

So, uh any thoughts? am I going to have to figure out a way to parse through the document and find the H1s myself? if so any thoughts about how to do that?

Thanks in advance


rnd me
08-07-2008, 06:02 PM
yeah. you will have to poke around the dom. design mode is a little dumb, using tags to style. h1 is already a tag, so that kinda limits your options.

you can write usable handler functions to apply css attribs to the object's style property, making your own execCommand sorta thing.

as far as referring to the dom, this article (http://www.mozilla.org/editor/ie2midas.html) might help you out: