Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Refresh parent onclose of child

Status
Not open for further replies.

mat41

Programmer
Mar 7, 2004
91
AU
Hello JS Masters

I can easily achieve this by placing a close window button of my own. However, is there a way to make it work this after the user clicks IE's red X?

Please note : I am coding in a strict IE 6.0 SP2 SOE using Classic ASP

TYIA
 
mat41, you can use the body unload event which works for all browsers I believe:

Code:
function doUnloadEvent()
{
if (window.event.clientX < 0 && window.event.clientY < 0)
{
alert("Window closing");
}
}

<body onunload="doUnloadEvent()">

Cheers

Nick
 
Thanks for your time however the unload event is not a good option. We dont want this firing if a user refreshes the page......This is just one of the obvious reasons.

Solution (can anybody see any floors?? it seems to work very well)

function closeSession()
{
//capturing ALT + F4
if (event.altKey==true && event.keyCode==0 )
{
//alert("closed1")
window.close();
if (window.opener && !window.opener.closed) {
window.opener.location.reload();
}

}

Xwidth=window.document.body.offsetWidth-window.event.clientX
YHeight=window.event.clientY
if(Xwidth<=30&&YHeight<0)
{
window.close();
if (window.opener && !window.opener.closed) {
window.opener.location.reload();
}
}

}
window.onbeforeunload=closeSession
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top