Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Apr 2007
    Posts
    17
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Exiting <h1> style in designmode

    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:

    execCommand('FormatBlock',false,'h1')

    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

    -Mike

  • #2
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Location
    Urbana
    Posts
    4,184
    Thanks
    10
    Thanked 569 Times in 550 Posts
    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 might help you out:
    my site (updated 13/9/26)
    BROWSER STATS [% share] (2014/1/19) IE7:0.2, IE8:6.7, IE11:7.4, IE9:3.8, IE10:4.4, FF:18.3, CH:43.6, SF:7.8, MOBILE:27.5


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •