[Javascript] Closing a pop-up containing a frameset when focus is lost

Rodney Myers rodney at aflyingstart.net
Tue Sep 4 12:01:56 CDT 2001


This is my best shot and is working OK in Win98 MSIE5.5 and NN4.7

Any improvments welcome.


// This is in the top frameset:

var aeWin=null;

//  opens the popup
function aepop(){
aeWin = window.open('addedit.htm','ae','<SNIP>');
}

// closes the popup
function closeWin(winHandle) {
if (winHandle && !winHandle.closed )
          {winHandle.close();}
}

function closeWin called from the main window main-frame files with this
handler in their <BODY> tags.

onfocus="top.closeWin(top.aeWin)"

Acknowledgements to 4.10 answer of http://jibbering.com/faq/#_4

Any thoughts?

TIA

Rodney


Rodney Myers wrote:

> Popup has two frames.
> One is navigational. The larger one contains various forms.
>
> The forms take data from, and pass data to, arrays and objects in the
> main window.
>
> While focus remains on the child window the pages and related objects in
> the main window (also a frameset) do not change. But once focus passes
> to the main window (or away from the child window) the presumption must
> be that a mismatch could arise between current states of the child/popup
> window data and the parent/main window.
>
> Therefore it seems to me prudent to close the child window if focus is
> lost. And there seems to be two ways of going about that:
>
> 1) If focus is on parent window and child window exists, close child
> window.
> Reliable code for testing child window existence cross-browser?
>
> 2) if focus is lost from child window close child window.
> What event of what object can I use? If I put onblur into the frameset
> the window closes as soon as it has opened.
>
> I want this to work in MSIE 4+ and NN4+
>
> TIA
>
> Rodney

--
Shop at ssistant Add-ons and Developer Workshops
http://www.aflyingstart.net/addons/

Enquiries regarding Shop at ssistant Classic training :
Call 01256 880770

Rodney Myers
Based in Oxford, England
Technical Director, Shop at ssistant eCommerce Solutions





More information about the Javascript mailing list