I have 3 pages on my site, Collaboration, Review, and Admin. Collaboration is a .aspx page with 2 iframes in it, the iframes are named collaborationFrame and timerFrame. The collaborationFrame has a .aspx file in it that opens up 2 other windows, the Review and Admin. So altogether you have the three main screens, Collaboration, Admin, and Review. I would like it so that when the user leaves or closes the Collaboration page that a confirm dialogue box shows up, and if the user clicks yes or ok to continue, it closes the Admin and Review windows. The following code that I have works just fine for this. If the user clicks ok the 2 windows (if opened) will close. But...
1. If the user clicks cancel, the collaboration page refreshes. This can't happen.
2. If the user simply closes the collaboration window, the confirm dialogue will not show up at all. If they try to refresh it or navigate away from it, it will work as intended. I need it to show up when the user attempts to close the window as well though.
Here is my code:
function UnloadPrompt()
{
var reviewConfirm="";
var adminConfirm="";
var and="";
var s="";
var reviewWindow = top.collaborationFrame.Rev
iew;
var adminWindow = top.collaborationFrame.Adm
in;
var confirmPrompt = null;
if ((reviewWindow!=null) && (adminWindow!=null))
{
reviewConfirm = "Review ";
adminConfirm = "Administration";
and = "and ";
s = "s";
confirmPrompt="yes";
}
else if (adminWindow!=null)
{
adminConfirm = "Administration";
confirmPrompt="yes";
}
else if (reviewWindow!=null)
{
reviewConfirm = "Review";
confirmPrompt="yes";
}
if (confirmPrompt=="yes")
{
if (confirm("Closing this window will close the "+reviewConfirm+and+adminC
onfirm+" window"+s+".\n\nAre you sure?")==true)
{
if (adminWindow!=null)
adminWindow.close();
if (reviewWindow!=null)
reviewWindow.close();
return true
}
else
{
return false
}
}
}
</script>
</head>
<body onunload="return UnloadPrompt();">
The code resides on the page that's in the timerFrame (iframe) right now, which is within the collaboration page. I did this in hopes that when pressing cancel the whole collaboration page wouldn't refresh but it doesn't make a difference. It exhibits the same behavior in the timerFrame as it does in the collaboration page.
Any ideas??
Start Free Trial