Subj : Re: race condition? window.open return value references self??? To : =?ISO-8859-1?Q?Georg_Maa=DF?= From : Igor Bukanov Date : Mon Feb 02 2004 11:01 am Georg Maaß wrote: > Fritz Schneider wrote: > >> When I was checking to see what objects are protected by the same >> origin policy, I noticed that the following script >> >> var w = window.open("http://www.yahoo.com"); >> w.onresize = function() { document.body.style.backgroundColor='red'; }; >> >> turns the window the script is in red. (Similar effect if you do an >> alert()). If instead you set the handler in a setTimeout for a short >> period of time, it has the expected behavior (having no effect). >> >> I also noticed that if you immediately read w's properties you can get >> screen x and y positions, the size of the window, and so on. Also you >> can get an HTMLBodyElement by reading w.document.body as well as other >> objects. >> >> If it's referencing an uninitialized window, why would the onresize >> get attached to the current document? If it's not, what gives? >> >> Thanks! > > > Wrong group. The objects related do not belong to JavaScript, they > belong to the host. So netscape.public.mozilla.dom fits better. > Well, this is JS scoping issue as well: document in function() { document.body.style.backgroundColor='red'; }; refer to the document of window where the script is declared, not the window the handler runs in. Use explicit reference to w as in: function() { w.document.body.style.backgroundColor='red'; }; .