当执行打印预览window.close无效

<html>
<head>
<script>
function printView(){
 alert("打印预览");
 WebBrowser.ExecWB(7,1);
 }
</script>
<title>
测试window.close
</title>
<OBJECT id="WebBrowser" classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2" height="0" width="0"></OBJECT>
</head>
<body>
1.点击打印览后,window.close变成无效,当前窗口关不掉
<input type="button" value="打印预览" onclick="printView()"/>
<input type="button" value="close" onclick="js:window.close();"/>
<br>
2.使用WebBrowser.ExecWB(45,1)可以在这种情况下关闭,而且不会弹出提示框
<input type="button" value="close2" onclick="js:WebBrowser.ExecWB(45,1)"/>
</body>
</html>

 

你可能感兴趣的:(window)