Closed Bug 281451 Opened 20 years ago Closed 20 years ago

document.body fails after window.open and doc.write with link tag.

Categories

(Core :: DOM: Core & HTML, defect)

x86
Windows XP
defect
Not set
normal

Tracking

()

RESOLVED INVALID

People

(Reporter: mgalli, Unassigned)

Details

The problem happens if you add links to external CSS via the link tag. 

CASE EXAMPLE WHICH WORKS
========================

otherWin=window.open("","windownamed","width=500,height=500");
otherWin.document.write("<html><head></head><body></body></html>");
otherWin.document.close();
otherWin.document.body.innerHTML="Hey I am here";

CASE EXAMPLE WHICH FAILS
========================

otherWin=window.open("","windownamed","width=500,height=500");
otherWin.document.write("<html><head><link rel='stylesheet' type='text/css'
href='' media='all'></head><body></body></html>");
otherWin.document.close();
otherWin.document.body.innerHTML="Hey I am here";

NOTES
=====
* For this second case, document.body is not there. 
* If you remove the href='' attribute from the LINK tag, it works. 
* Also if you put a valid css file there is still breaks.
<link> tags block further parsing until the stylesheet loads, so when you're
accessing document.body the <body> tag has not been parsed yet.

The same would happen if you wrote out <script> tags.
Status: NEW → RESOLVED
Closed: 20 years ago
Resolution: --- → INVALID
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.