Closed Bug 675399 Opened 14 years ago Closed 14 years ago

JavaScript weirdness / interpretation difference between Firefox and other browsers involving document.write inside setInterval call

Categories

(Core :: JavaScript Engine, defect)

defect
Not set
normal

Tracking

()

RESOLVED INVALID

People

(Reporter: Tobbi, Unassigned)

Details

Attachments

(1 file)

Attached file testcase
This literally is the reason why I'm still in the office, although it being off working hours... Calling document.write inside a setInterval call doesn't continously add a's to the page, as expected. It works in Google Chrome and Safari as expected. This is the JS code: function increment() { document.write("a");} var ID = document.addEventListener("DOMContentLoaded", function() { window.setInterval("increment();", 1000); });
You're calling document.write() after parsing is done. Per http://www.whatwg.org/specs/web-apps/current-work/multipage/content-models.html#dom-document-write step 3, this triggers a call to open(). Then http://www.whatwg.org/specs/web-apps/current-work/multipage/content-models.html#dom-document-open step 12 replaces the window associated with the document with a new window. The list of timeouts is attached to the old window, so goes away. WebKit just gets this wrong. Please report the problem to them....
Status: NEW → RESOLVED
Closed: 14 years ago
Resolution: --- → INVALID
Opera gets this right too.
Alright, thanks for the clarification!
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: