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 4 of 4
  1. #1
    New Coder
    Join Date
    May 2004
    Posts
    22
    Thanks
    0
    Thanked 0 Times in 0 Posts

    execCommand causes body to scramble?

    Hello,

    I am using execCommand(bold,false, null) in Mozilla 1.6 to make a selection, that the user created, bold.

    This command works fine and the selected text does go bold, however I get weird stuff happening to the content before and/or around the content that was just bolded.

    Here is an example:

    A small line of text is in the window.

    Text view:
    --------------------------------------------
    This is a formatting test. This is Word format.
    --------------------------------------------
    Html view:
    --------------------------------------------
    <div class="section1064style178">This is a formatting test. <span class="section1064style178" style="font-style: italic;">This</span> is word format.</div>
    --------------------------------------------

    The user selects "formatting" from the text below and hits the bold button which calls the execCommand.

    This is what happens:

    Text view:
    --------------------------------------------
    formatting This is a test. This is word format .
    --------------------------------------------


    When I switch between html view and text view all of a sudden it formats it correctly.

    Text view:
    --------------------------------------------
    This is a formatting test. This is word format .
    --------------------------------------------

    Html view:
    --------------------------------------------
    <div class="section1064style178">This is a <span style="font-weight: bold;">formatting </span>test. <span class="section1064style178" style="font-style: italic;">This</span> is word format.</div>
    --------------------------------------------

    Is this a rendering issue? Do I need to call a refresh or something after I use an execCommand in mozilla? This is quite baffling to me.

  • #2
    jkd
    jkd is offline
    Senior Coder jkd's Avatar
    Join Date
    May 2002
    Location
    metro DC
    Posts
    3,163
    Thanks
    1
    Thanked 18 Times in 18 Posts
    Sounds like a repainting issue? What version of Mozilla are you using? Try running it in Firefox 0.8 or the latest Mozilla nightly and see if the problem replicates itself.

  • #3
    Master Coder
    Join Date
    Feb 2003
    Location
    UmeŚ, Sweden
    Posts
    5,575
    Thanks
    0
    Thanked 83 Times in 74 Posts
    Sound like one of the should-but-don't trigger rerendering bugs.
    liorean <[lio@wg]>
    Articles: RegEx evolt wsabstract , Named Arguments
    Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
    Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards

  • #4
    New Coder
    Join Date
    May 2004
    Posts
    22
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Here is the mozilla version I am running:

    (1.6)
    Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.6) Gecko/20040113

    I also tried Firefox:

    (0.8)
    Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.6) Gecko/20040206 Firefox/0.8


    The content in the example is held in an editable document in an iframe. So I tried this:

    Code:
    this.iframe.style.display = "none";
    this.iframe.style.display = "block";
    
    //set it back to designMode
    this.edit.designMode='on';
    This does fix the rendering problem, however you can see the content quickly jump from scrambled to formatted correctly.

    I'm downloading mozilla 1.7rc to give it a go.

    Well, 1.7rc does it as well.
    Last edited by iceboxqs; 06-02-2004 at 11:56 PM.


  •  

    Posting Permissions

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