HighDots Forums  

window.onload being ignored for child in IE

Javascript JavaScript language (comp.lang.javascript)


Discuss window.onload being ignored for child in IE in the Javascript forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Beni Rose
 
Posts: n/a

Default window.onload being ignored for child in IE - 06-12-2008 , 11:28 AM






I'm trying to open a new window using window.open and then print that
window once it's loaded. It works fine in Firefox, but not at all in
IE. No matter what I put in my onload, it gets ignored. Here's the
code:

function openPrintPage(loc)
{
var printWin = window.open(loc+'?
dl=false','printpage','width=600,height=800,locati on=no,menubar=no,directories=no,status=no,toolbar= no,scrollbars=yes,resizable=yes');
printWin.onload = function()
{
printWin.print();
}
}

Even if I just put an alert in that printWin.onload, it doesn't do
anything. My only guess is that the page has loaded before the onload
function gets assigned, but I can't figure out a way to assign it
otherwise.

Reply With Quote
  #2  
Old   
Henry
 
Posts: n/a

Default Re: window.onload being ignored for child in IE - 06-12-2008 , 11:53 AM






On Jun 12, 5:28 pm, Beni Rose wrote:
Quote:
I'm trying to open a new window using window.open and then
print that window once it's loaded. It works fine in Firefox,
but not at all in IE. No matter what I put in my onload, it
gets ignored. Here's the code:

function openPrintPage(loc)
{
var printWin = window.open(loc+'?
snip
printWin.onload = function()
{
printWin.print();
}

}

Even if I just put an alert in that printWin.onload, it doesn't
do anything. My only guess is that the page has loaded before
the onload function gets assigned, but I can't figure out a way
to assign it otherwise.
In reality IE assigns an onload value as a page loads and when that
page does not define an onload handler of its own (is a script or as
an attribute in the opening body tag) it ends up assigning the null
value to onload. Thus you just cannot successfully assign to the
onload property of the object returned from - window.open -.


Reply With Quote
  #3  
Old   
SAM
 
Posts: n/a

Default Re: window.onload being ignored for child in IE - 06-12-2008 , 11:56 AM



Beni Rose a écrit :
Quote:
I'm trying to open a new window using window.open and then print that
window once it's loaded. It works fine in Firefox, but not at all in
IE. No matter what I put in my onload, it gets ignored. Here's the
code:

function openPrintPage(loc)

perhaps ... :


function openPrintPage(loc)
{
var attr = 'width=600,height=800,'+
'location=no,menubar=no,directories=no,'+
'status=no,toolbar=no,scrollbars=yes,resizable=yes '
if(typeof printWin == 'undefined' || printWin.closed)
{
printWin = window.open('','',attr);
}
printWin.onload = printWin.print; // or = window.print;
printWin.location = loc+'?dl=false';
}

--
sm


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.