[Javascript] window.open() not working in onLoad() of Mozilla 1.5

Hakan Magnusson hakan at backbase.com
Wed May 5 01:23:39 CDT 2004


> Question:  Is there a way to load a div with the html content of a separate URL after a page has been initially rendered?  I've been using iframes recently in IE6 but find them a bit awkward to control. 

It is possible to use the XML HTTPrequest-object in both Mozilla and 
Internet Explorer to dynamically load virtually any type of source data 
at "run-time". This HTTPrequest will have the raw text of your file in 
its responseText-property.

This gets more and more complicated depending on what you want to load 
(inline scripting, for example, need special massage in Internet 
Explorer to work) and if you're planning on using the XML-facilities of 
the HTTPrequest-object you need to make sure that the source you are 
loading is in fact valid XML/XHTML.

As a first (and easier) step, I'd suggest using an iframe with it's 
display set to none, load whatever data you want in the iframe and then 
either import the root node to your "main" document or simply copy the 
innerHTML of the iframe body.

Regards,
H

Paul Novitski wrote:
> At 06:01 AM 5/4/2004, Mike Dougherty wrote:
> 
>> I've never used a real window.open(ing) popup, because this strategy 
>> keeps the content in the document and allows direct references to the 
>> "parent" document (because the 'popup' is actually part of the DOM tree)
> 
> 
> 
> Ah, but Mike, if you had ever worked with window.open() you'd know that 
> the child window and its parent (and its siblings in the case of 
> multiple pop-ups) are in full communication with one another through the 
> DOM, as thoroughly as a div or any other tag within the parent window 
> itself.
> 
> parent access to child:
>         var oChild = window.open(sURL, sName, sArgs)
>         oChild is the child window object
>         e.g., oChild.document.location = "http://..."
>         e.g., oChild.document.getElementById("DivInsideChild")
> 
> child access to parent:
>         window.opener is the parent window object
>         e.g., window.opener.document.location = "http://..."
>         e.g., window.opener.document.getElementById("DivInsideParent")
> 
> In my own work, the main advantage of using a div for a pop-up is that I 
> can build its chrome from scratch and don't have to worry about trying 
> to suppress the O/S window chrome, while the main advantage of 
> .open()ing a new window is that I can easily load it with the src of a 
> new URL on the fly.
> 
> Question:  Is there a way to load a div with the html content of a 
> separate URL after a page has been initially rendered?  I've been using 
> iframes recently in IE6 but find them a bit awkward to control.
> 
> Paul
> 
> 
> At 06:01 AM 5/4/2004, you wrote:
> 
>> How difficult would it be to populate a <div id='popscreen' 
>> style='display: none; z-index:100; position:absolute; top:X; left:Y;'> 
>> with the contents of your popup, then in some other object:
>> onClick="document.getElementById('popscreen').style.display='inline'; "
>>
>> I've never used a real window.open(ing) popup, because this strategy 
>> keeps the content in the document and allows direct references to the 
>> "parent" document (because the 'popup' is actually part of the DOM tree)
>>
>> What do you [all] think of this plan?
> 
> 
> 
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> https://lists.LaTech.edu/mailman/listinfo/javascript
> 
> 



More information about the Javascript mailing list