Wrox Home  
Search P2P Archive for: Go

  Return to Index  

javascript thread: window.closed property in NN 6.23 or up


Message #1 by arsal01@h... on Thu, 14 Nov 2002 03:30:10
HI - here is what I am doing

I have using several popups and the innitial problem was that People can 
log off in the Parent window and  the Popup (child window) remained 
opened - we didnt like that idea -

So we come up to check for these events in Body tag
onfocus
onclick
onunload

so that if the popup is opened and u try to either go to Parent or 
somewhere it will Prompt you (confirm dialog) that Do u want to close the 
window - if yes then just close the window and if not the focus the child 
window - 

That worked fine using

<Body onfocus="if (window.newwin) ClosingOption();" onclick="if 
(window.newwin) ClosingOption();" onunload="if (window.newwin) 
ClosingOption();">

But in NN it start giving problem for instance if you cross the window 
using its right top cross (X) - then it wont prompt you for confirm 
dialog -

here is how I am handling ClosinOption() function

function ClosingOption() { 
 
if (!newwin.closed )  { 
  if (window.newwin!=null) {
	   if (locked) {
	   locked = false;

	   var opt=window.confirm("<%=nlsMsgFinder.getMessage
("UITEXT_DO_YOU_WANT_TO_CLOSE_THE_POPUP_WINDOW")%>");
		 if (opt) {
			newwin.close();
			window.newwin=null;
			document.windowform.windowstatus.value="1"; 

		 }
		 else {
			if (window.newwin!=null) {
			document.windowform.windowstatus.value="2";
			newwin.focus();

			}
		  }
	   setTimeout("Unlocking();",1000);
		   }
   }
   else {
	 var mainwin=window.confirm("<%=nlsMsgFinder.getMessage
("UITEXT_DO_YOU_WANT_TO_CLOSE_THE_MAIN_WINDOW")%>");
	 if (mainwin)
	 window.close();
   } 
 }
 
}

---------------------------------------------------------------------
with your help last time I come to work 2 different version of the above 
Body Tag using your way of typeof(newwin)!="undefined" and the other way

I got the solution for that two
I am checking Browsers and the using document.write("<Body.....");
writing the body tag ---- 


I hope that clearifies the entire problem ---- 

many thanks for your help
Arsalan



> I don't know if it would work properly in IE.  Do you remember that =
I've
mentioned this point at the very beginning?

If you don't tell what you want to do, I don't think I can help any =
further.

> -----Message d'origine-----
> De : arsal01@h... [mailto:arsal01@h...]
> Envoy=C3=A9 : jeudi 14 novembre 2002 21:24
> =C3=80 : javascript
> Objet : [javascript] Re: window.closed property in NN 6.23 or up
>=20
>=20
> Hi -
> Yes It works !! -- Thanks - But the problem is that it doesnt=20
> work with IE=20
> or may be i dont know if i have to tweak it little bit - in=20
> short now I=20
> have 2 HTMLs one supporting NN other IE - I wrote code in=20
> Javascript to=20
> check for what browser it is but i dont know how to place html using=20
> Javascript -=20
>=20
> So now I have:
> FOR NN:
> <BODY onunload=3D"if (window.newwin) ClosingOption();" onclick=3D"if=20
> (window.newwin) ClosingOption();" onfocus=3D"if (typeof(newwin)!
> =3D"undefined") ClosingOption();" >
>=20
> FOR IE:
> <BODY onunload=3D"if (window.newwin) ClosingOption();" onclick=3D"if=20
> (window.newwin) ClosingOption();" onfocus=3D"if (window.newwin)=20
> ClosingOption
> ();" >
>=20
> Arsalan

  Return to Index