简体   繁体   English

在JavaScript中关闭子窗口的onunload事件

[英]Closing child windows onunload event in javascript

I am working on a project that has an onload event of 我正在一个项目的onload事件

var opsWin = window.open ('url','_blank', 'options);
var preWin= window.open ('url','_blank', 'options);
var pkgWin= window.open ('url','_blank', 'options);
var apcWin= window.open ('url','_blank', 'options);

opsWin.focus();
preWin.focus();
pkgWin.focus();
apcWin.focus();

These popups displays 4 different PDFs that the user needs to see before proceeding. 这些弹出窗口显示用户在继续操作之前需要查看的4个不同的PDF。 My problem comes on my onunload event: 我的问题来自我的onunload事件:

function unLoadDocs(){
alert(opsWin) 
opsWin.close();
preWin.close();
pkgWin.close();
apcWin.close();
}

My alert is for debugging purposes, to make sure I make it there and to see that opsWin actually exists(it does make it there and it does exist and in scope). 我的警报是出于调试目的,请确保将其放置在其中,并查看opsWin实际上存在(它确实在其中存在并且确实存在并且在范围内)。 My problem is that the documents are not closing in Internet Explorer 10. I try the same script in Mozilla Firefox, and it works perfectly. 我的问题是文档没有在Internet Explorer 10中关闭。我在Mozilla Firefox中尝试了相同的脚本,并且运行良好。

Some insight as to why these windows won't close on Internet Explorer 10 would be great.(I have also tried IE9 with no success) 关于为什么这些窗口无法在Internet Explorer 10上关闭的一些见解将是很棒的。(我也尝试了IE9,但没有成功)

The popups were PDF's, so adobe reader was holding it open/had a different handle. 弹出窗口是PDF的,因此adobe阅读器将其保持打开状态/具有不同的句柄。 Ultimately, I opened another window with a 100% width and height i-Frame and embedded the PDF in the i-Frame. 最终,我打开了另一个宽度和高度为100%的i-Frame窗口,并将PDF嵌入到i-Frame中。 I was then able to close the windows with the unload function above. 然后,我可以使用上面的卸载功能关闭窗口。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM