[Chameleon] Close popups when main window closes

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


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?' );
   if (window.opera) // Opera
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()});

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

More information about the Chameleon mailing list