The following code will close a popup window after the user selects to download the file, or if he/she cancels the download.
Between the <head></head> tags of the document is popped up, add the code below:
<script language="JavaScript">
function checkVar() {
if(document.frm.winFocus.value==1) {
window.close();
}
}
function changeVar() {
document.frm.winFocus.value=1;
}
</script>
In the <body> tag add this:
<body onFocus="checkVar();">
Somewhere in the body of the document add:
<form name="frm">
<input type="hidden" name="winFocus" value="0">
</form>
And finally wherever you need them, the links:
<p class="normal">Download ?
<a href="fileToDownload.zip" onClick="changeVar();" class="zipLink">Yes</a>
<a href="javascript:;" onClick="window.close();" class="zipLink">No</a></p>
Note: This works for both Internet Explorer and FireFox.