下面的例子当点击 关闭弹出窗口 按钮时,使用 open() 方法弹出的窗口会被关闭:
<html>
<head>
<script type="text/javascript">
function closeWindow()
{
myWindow.close()
}
</script>
</head>
<body>
<script type="text/javascript">
myWindow=window.open('','','width=200,height=100')
myWindow.document.write("弹出窗口")
</script>
<button onclick="closeWindow()">关闭弹出窗口</button>
</body>
</html>