首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

如何在window.open关闭后执行js函数

2013-09-23 
怎么在window.open关闭后执行js函数用的是window.open,需要在关闭后执行一个js方法由于弹出的界面上需要通

怎么在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>

热点排行