[Chameleon] Close popups when main window closes

Berend Veldkamp berend.veldkamp at aris.nl
Tue Dec 13 10:10:04 EST 2005


Hi,

I'd like to close any popup when I close the main application window, so 
I changed CWCPopup->DrawPublish() to include the following Javascript:

var wh = window.open('{$url}', '{$name}', '{$options}');
if (!wh)
{
   alert( 'unable to open popup dialog.  Perhaps you have a popup 
blocker installed?' );
}
else
{
   if (window.opera) // Opera
     window.opera.addEventListener("BeforeEvent.unload", 
function(){wh.close()}, false);
   else if (window.addEventListener) // W3 DOM
     window.addEventListener("unload", function(){wh.close()}, false);
   else if (window.attachEvent) // IE
     window.attachEvent("onunload", function(){wh.close()});
   wh.focus();
}

This works for IE and W3 DOM compliant browsers, but not Opera, can 
anyone tell me what I do wrong?

And another thing: With this approach, the Javascript code is duplicated 
for each popup that I use, is it possible to include this only once, as 
a separate function?

If I get this working, would it be possible to include this in the main 
Chameleon distribution, so I don't have to change my own application 
after an upgrade?

Thanks, Berend


-- 
____________________________

Berend Veldkamp - ARIS
http://www.aris.nl/
____________________________


More information about the Chameleon mailing list