Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

window.close problem in IE

Status
Not open for further replies.

JimHH

Programmer
Jan 16, 2001
12
0
0
US
I have a main form with a number of (popup) subforms.

Each popup is defined to be 'dependent' on the main form, i.e. should close automatically when the main form is closed/reloaded.

Everything functions OK, but there is a browser-related difference: NS 4.x and NS 6.x show only one browser item on the bottom task bar; MS IE (6.2 in my case) shows the main browser task plus each subform as a separate item.

When I close/reload under NS there is no problem -- the task bar reflects the new situation.

Under MS IE 6.2 all the subforms remain as orphans, and throw an error when I manually close them.

In the code (included below, showing just one popup) I have included a redundant provision: when the main form unloads it checks each subform, and attempts to close it if open -- this line of code is executed but does not close the subform.

TIA for help with this problem ...

JimHH

Code:
<script language=&quot;javascript&quot;>
var myWindow2 = null;
function Subbtn2() {
if ((myWindow2 !=null) && (myWindow2.open))
  {
  myWindow2.focus();
  }
else
  {
  myWindow2=window.open('form_2.htm','myWindow2','dependent, ... etc ...');
  if (myWindow2.opener == null) myWindow2.opener = self;
  }
}
// Called from myWindow2 when manually closed
function null_2() {
  myWindow2 = null;
}
function on_load() {
Subbtn2();
myWindow2.blur();
}
//
function un_load() {
if (myWindow2 !=null && myWindow2.open) 
  {
  // *** FOLLOWING LINE EXECUTES BUT HAS NO EFFECT ***
  myWindow2.close();
  }
}
//-->
</Script>
</head>
<body onLoad=&quot;return on_load();&quot; onUnload=&quot;return un_load();&quot;>
:
</body>
</html>
 

Addendum:

I just tried this with Opera 6.0 -- it fails to create the popups ...

JimHH
 
I just checked your code:
it works very well in Opera 6.0, IE5 and Netscape 6.2

 
starway wrote:
> I just checked your code:
> it works very well in Opera 6.0, IE5 and Netscape 6.2

Many thanks starway ... your reply puzzled me.

So I started cleaning up the code on my live site to provide you with a link, then found that it was working OK for me too -- I must have cleaned out something which I thought was extraneous, but in fact was critical.

At least, it now works in IE and NS, which are the browsers of current concern -- but not yet in Opera. (I can work on that later).

Thank you for your interest, which headed me in the right direction (whatever that was!).

JimHH
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top