Skip to content
Advertisement

why can’t i set window.onload in IE8?

I have the following function, which works fine in Firefox, but will do nothing in IE8

function print(url) {
    var w = window.open(url);
    w.onload = function() {
        w.print();
    };
}

I want to open a webpage and immediately open the print dialogue.

Advertisement

Answer

If you have the hand on the page at url, place the call there. In the HTML, at the end of the BODY tag. Add a SCRIPT tag with your call

<body>
  ...
  <script>
    window.print();
  </script>
</body>
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement