...

View Full Version : execCommand causes body to scramble?



iceboxqs
06-02-2004, 08:40 PM
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.

jkd
06-02-2004, 10:30 PM
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.

liorean
06-02-2004, 10:51 PM
Sound like one of the should-but-don't trigger rerendering bugs.

iceboxqs
06-02-2004, 11:41 PM
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:



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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum