I need a javascript function where it opens a popup whenever a user closes the window, then in the actual window i need to be able to close that original page that the user tried to close(if the user clicks "I'm sure i want to close" or something)
function openWin()
{
function linkClick(e) {
alert = false;
}
links = document.getElementsByTagName('a');
for (i = 0; i < links.length; i++)
links[i].addEventListener('click', linkClick, false);
if(alert != false){
myWindow=window.open("","","width=200,height=100");
myWindow.document.write("<p>This is 'myWindow'</p>");
}
}
then in the body i have a on unload function
<body onUnload="openWin()" >
the popup works but it appears when you click a link too
any ideas?