简体   繁体   中英

Closing child windows onunload event in javascript

I am working on a project that has an onload event of

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. My problem comes on my onunload event:

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). 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.

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)

The popups were PDF's, so adobe reader was holding it open/had a different handle. Ultimately, I opened another window with a 100% width and height i-Frame and embedded the PDF in the i-Frame. I was then able to close the windows with the unload function above.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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