{ib}document.write causes duplicated content




17 years ago
3 years ago


(Reporter: mgalli, Assigned: waterson)



Dependency tree / graph

Firefox Tracking Flags

(Not tracked)




(1 attachment)



17 years ago
This is one special case from AOL site in Brazil. Note that the page have
content duplicated in the middle. I simplified the page to the following testcase:

This is content

Mozilla is displaying the content between the script areas twice. 
When I verify the generated content in the DOM, it's not duplicated, only in the
screen. Note that if you select the second text, this will actually select the

Confirmed with: Gecko/20020430

Comment 1

17 years ago
Created attachment 81814 [details]
Simple testcase 1

Comment 2

17 years ago
Changing OS to all. 
OS: Linux → All
Summary: document.write causes duplicated content → document.write causes duplicated content
more block-in-inline ugliness. :(
Hardware: PC → All
Summary: document.write causes duplicated content → {ib}document.write causes duplicated content

Comment 4

17 years ago
Assignee: attinasi → waterson


17 years ago
Keywords: testcase

Comment 5

17 years ago
Changing priority to P2
Priority: -- → P2


17 years ago
Target Milestone: --- → Future

Comment 7

14 years ago
worksforme with linux trunk 2005041521
is anybody still seeing this?
I see the duplicate output on Mozilla 1.7.11 Linux but not on 
branch nightly build
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8b4) Gecko/20050827 Firefox/1.0+

-> WFM.
Researching the topic of document.write(), I found a way to create duplicate
output even on Deer Park 
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8b4) Gecko/20050827 Firefox/1.0+

See the testcase: http://www.mobotix-service.de/~daniel/docwrite/

It contains two buttons, an iframe (top), a debug log (bottom) and javascript
code. If you press a button, the js code writes a small html document into the
iframe which contains <SCRIPT SRC=...> in the document head, effectively loading
javascript code. With the buttons you choose which script to load:
 left button : http://www.mobotix-service.de/~daniel/docwrite/alert.js
 right button: http://www.mobotix-service.de/~daniel/docwrite/documentwrite.js 

The latter contains two document.write calls and a callback to the parent page
(the one containing the iframe), sending a message to the debug log.

If you open the testpage and press the right button, this is what appears in the

Hello! The current date and time is: Thu Sep 01 2005 18:13:10 GMT+0200 (CEST)
Hello! The current date and time is: Thu Sep 01 2005 18:13:10 GMT+0200
(CEST)IFrame Body starts here

The debug log message is missing, instead the javascript console shows an error:
Error: document has no properties
Source File: http://www.mobotix-service.de/~daniel/docwrite/documentwrite.js
Line: 2

Some questions arise:
- How does Gecko handle output of character data inside the document head?
- Does the script inside the iframe overwrite itself by calling document.write? 
- Why doesn't the output duplicate when documentwrite.js is included in a
"normale" browser frame, see 
- Is this problem created because the content of the iframe itself is created
dynamically and not just loaded through a src attribute?

Comment 10

13 years ago
I cannot submit a reliable example, but the Web interface to our application has been exhibiting issues that are almost certainly related to this bug...

On login, we load a three-frame document, with one hidden frame for "pseudo-AJAX" updates, a menu frame, and an application page frame.  The initial application frame is loaded with an image and a "quick-select" input box.  When the user enters a selection into the input box and presses ENTER or clicks the submit button, a form on the page is filled out and the onsubmit() function triggered; this targets the hidden frame, which loads JavaScript to replace the application page.  Occasionally, instead of replacing the application page, it appears to intersperse the new content with the old; the new content appears (mostly hidden) underneath the initial image, and DOM Inspector shows the new page elements as having been inserted BEFORE the image from the initial screen.  Likewise, header scripts appear to be duplicated, with new scripts appearing AFTER old scripts.  The stylesheet may also be loaded twice, though my only evidence of that so far is the resizing of the quick-select input label (our text elements are rendered in % from a fixed-pixel base...)  As with the example below, the JavaScript console shows "document has no properties" when this occurs.

According to spec, document.write() should either (a) append to a not-fully-rendered page, or (b) clear and replace a fully-rendered page.  This appears to be neither of the above...
QA Contact: chrispetersen → layout
Testcase works for me.  Please file a new bug if the problem still occurs in a recent Firefox.
Last Resolved: 3 years ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.