window.onload being ignored for child in IE

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Beni Rose

    window.onload being ignored for child in IE

    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(l oc)
    {
    var printWin = window.open(loc +'?
    dl=false','prin tpage','width=6 00,height=800,l ocation=no,menu bar=no,director ies=no,status=n o,toolbar=no,sc rollbars=yes,re sizable=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.
  • Henry

    #2
    Re: window.onload being ignored for child in IE

    On Jun 12, 5:28 pm, Beni Rose wrote:
    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(l oc)
    {
    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 -.

    Comment

    • SAM

      #3
      Re: window.onload being ignored for child in IE

      Beni Rose a écrit :
      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(l oc)

      perhaps ... :


      function openPrintPage(l oc)
      {
      var attr = 'width=600,heig ht=800,'+
      'location=no,me nubar=no,direct ories=no,'+
      'status=no,tool bar=no,scrollba rs=yes,resizabl e=yes'
      if(typeof printWin == 'undefined' || printWin.closed )
      {
      printWin = window.open('', '',attr);
      }
      printWin.onload = printWin.print; // or = window.print;
      printWin.locati on = loc+'?dl=false' ;
      }

      --
      sm

      Comment

      Working...