'How to Close Window at onload event of body at IE 8 and IE 7?
I use this code window.onload=function Print(){window.open(); window.close()} at YouPrint.aspx. It working fine at IE 9 but it does not work in IE 8 and IE 7. It shows a JavaScript error like this "Stack Flow error". Why? If you have solution, please show me the way to solve this problem. Please Help me.
Solution 1:[1]
Works ok for me in IE7 / IE8 using the following test file:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<body onload="window.print(); window.close();">
<span>Test</span>
</body>
</html>
What doc type are you using? I've tested it with strict and that works too. More info please...
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | LFN |
