日期:2014-05-17  浏览次数:20969 次

怎么在window.open关闭后执行js函数
用的是window.open,需要在关闭后执行一个js方法


由于弹出的界面上需要通过流下载文件所以用的是window.open,
用window.showmodaldialog下载不了文件
js 界面 window.open

------解决方案--------------------
在打开的窗口的unload事件中写代码呗。
------解决方案--------------------
只有通过子窗口调用父窗口的方式实现
------解决方案--------------------

<html>
<head>
<script type="text/javascript">
function open_win() 
{
window.open("open.html")
}

function test(){
alert("parent");
}
</script>
</head>

<body>
<form>
<input type=button value="打开窗口" onclick="open_win()">
</form>
</body>

</html>







<html>
<head>
<script type="text/javascript">
function test(){
alert("close");
}
</script>
</head>

<body onunload="window.opener.test()" onbeforeunload ="test()">
<form>
</form>
</body>

</html>