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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Closing Netscape browser window

Status
Not open for further replies.

BG12424

Programmer
Jun 4, 2002
717
US
Is there a way to programmatically close the browser with javascript if the visitor manually comes to that page without it being opened from script? I can't seem to find anything that permits me to simulate a "self.close();" routine. Thanks

regards,
Brian
The problem with doing something right the first time is that nobody appreciates how difficult it was.
 
I would pass a query string along when I open the browser from script. Then on the onload event of that browser, check for this query string, if it's not there, close the browser.
 
Right, but closing the window with javascript does not work. Actually, the link on the main window is a logout link and in IE it works just fine when I do a self.close, but in Netscape, it does not.

regards,
Brian
The problem with doing something right the first time is that nobody appreciates how difficult it was.
 
No, try adding this to a page and open with Netscape

Code:
<a href="#" onclick="javascript:self.close();">close window</a>

regards,
Brian
The problem with doing something right the first time is that nobody appreciates how difficult it was.
 
...sorry, don't have Netscape to test that ....

How about
<a href="#" onclick="window.close()">close window</a>
 
according to that link, this will work:

<a href="#" onClick="top.close();">close window</a>
 
The top.close() does not work in Netscape 7.2 or FireFox. Any other ideas?



regards,
Brian
The problem with doing something right the first time is that nobody appreciates how difficult it was.
 
I just tested it in FireFox, the window.close and top.close() work just fine.

Sorry ... can't help.
 
In what conditions will the top.close() work, because it doesn't close using FireFox or Netscape when I click on the hyperlink. It does close in IE.

<a href="#" onClick="top.close();">close window</a>

regards,
Brian
The problem with doing something right the first time is that nobody appreciates how difficult it was.
 
With FF, this will work

<a href="#" onClick="top.close()">close window</a>

Note: no ";" after window.close()
 
I should clarify this:

<a href="#" onClick="top.close()">close window</a>

If you open a FF browser NOT from a script, a confirm msg will popup for you close or cancel. If you open FF browser from a script, the about code will close the browser without the confirm msg.
 
Does this work when opening an HTML file as a File, or only on a domain? should it matter? I removed the ";" after the close() and it did not work.

file:///C:/Documents%20and%20Settings/nfisbjg/Desktop/closewindow.html

regards,
Brian
The problem with doing something right the first time is that nobody appreciates how difficult it was.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top