can't use javascript object twice

RESOLVED DUPLICATE of bug 114461

Status

()

Core
DOM: Core & HTML
RESOLVED DUPLICATE of bug 114461
15 years ago
15 years ago

People

(Reporter: zvodar philippe, Assigned: jst)

Tracking

Trunk
x86
Windows XP
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

15 years ago
User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.1) Gecko/20020826
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.1) Gecko/20020826

Look at these 2 files:

file 1: test.js
---------------

var test = new Object( );
test.version = "1";

file 2: test.html
------------------
<html>
<head>
<title>test</title>
<script language="javascript" src="test.js"></script>
<script language="javascript">
main = function( ) {
  document.write( test.version + "<br>" );
  document.write( test.version + "<br>" );
}
window.onload = main;
</script>
</head>
<body>
</body>
</html>

Only the first "document.write" works, the other one failed with a "test is not
defined" error message in javascript console...


Reproducible: Always

Steps to Reproduce:
1.
2.
3.

Comment 1

15 years ago
Confirming bug with Mozilla trunk binary 20020924xx on WinNT.
This has something to do with document.write(), because if we
replace it in the testcase with alert(), we do not see the bug.

Reassigning to DOM Level 0 -
Assignee: rogerl → jst
Status: UNCONFIRMED → NEW
Component: JavaScript Engine → DOM Level 0
Ever confirmed: true
QA Contact: pschwartau → desale
Um... document.write in the onload handler (after the document has finished
loading) implicitly calls document.open() and thus wipes out the old document
and therefore the old script context (clearing the JS scope in the process).  We
already have bugs on this; not sure whether they're resolved (invalid, wontfix,
etc) or not.
*** Bug 170907 has been marked as a duplicate of this bug. ***
Duplicate of bug 114461 - "document.open clobbers js context"

*** This bug has been marked as a duplicate of 114461 ***
Status: NEW → RESOLVED
Last Resolved: 15 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.