Closed Bug 297370 Opened 20 years ago Closed 19 years ago

Browser can't change CSS-Style attributes of Document in newly opened Window

Categories

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

x86
Windows XP
defect
Not set
minor

Tracking

()

RESOLVED INVALID

People

(Reporter: tux, Unassigned)

Details

User-Agent:       Mozilla/5.0 (X11; U; Linux i686; de-DE; rv:1.7.8) Gecko/20050513 Firefox/1.0.4 (Debian package 1.0.4-1)
Build Identifier: Mozilla Firefox Version 1.0.4

If I open a new Window with JavaScript like in:
  var wdw = window.open(document.location);
then I can't modify the CSS-Attributes of the <div> Tags in the Document like in:
  wdw.document.getElementById("IdOfDivTag").style.width="100px";

Strangely it works if I open another Window with:
  var bla = window.open();
  bla.close();
or with:
  alert("BLA");
before trying to change the Attributes of the <div> Tags.
When the new (3rd) Window closes the Changes appear as wished in the 2nd one.

This happens on Mozilla (newest build), Firefox 1.0.4, Netscape 8 and Opera.
Therefore it works in the Microsoft Internet Explorer. Since this behaviour does
not seem logical to me I guess it's a bug.

Reproducible: Always

Steps to Reproduce:
1. create new window: var wdw = window.open(document.location);
2. change some attributes with getElementById():
wdw.document.getElementById("IdOfDivTag").style.width="100px";

Actual Results:  
nothing, the page in the new window looks exactly the same as in the 1st one

Expected Results:  
Changed the <div> Tags Attributes.
window opening is asynchronous...
Assignee: general → general
Component: General → DOM: Level 0
Product: Mozilla Application Suite → Core
QA Contact: general → ian
Version: unspecified → Trunk
(In reply to comment #1)
> window opening is asynchronous...

Exactly.

> If I open a new Window with JavaScript like in:
>   var wdw = window.open(document.location);
> then I can't modify the CSS-Attributes of the <div> Tags in the Document like in:
>   wdw.document.getElementById("IdOfDivTag").style.width="100px";

That's because the window is created before the url of document gets actually
loaded in the window. The fetching and loading of the URL only starts after the
current script block finishes executing.

Resolving as INVALID since the current behavior is correct.
Status: UNCONFIRMED → RESOLVED
Closed: 19 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.