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

window.close() with Netscape

Status
Not open for further replies.

minonees

Programmer
May 11, 2001
6
AE
Hi everybody,
I'm tryin' to prevent users from browsin' my website usin' Netscape, I'm usin' the followin' code:

<script language=&quot;javascript&quot;>
<!--
function detect_browser()
{
if (navigator.appName != &quot;Microsoft Internet Explorer&quot;)
{
alert(&quot;Please use IE to browse this Website.&quot;);
window.close();
}
}
-->
</script>

<BODY onLoad=&quot;detect_browser()&quot;></BODY>

But when I browse the website usin' Netscape, I get the alert message, but Netscape shows a dialog box asking me if I wish to close the window or not. I wanna close the window without askin' the users. The window.close() works good with IE.

With regards
 
the only time window.close() is not going to show that box is if you have opened the window yourself from another page -- that gives you ownership of the window, and then you can do whatever you want with it --

If you want the easiest IE detector, you can use this:

if (document.all)

if that's true, then they are using IE -- if it's false, they're not --

I use that for our intranet, and then just use a:
location='getIE.htm';

to let them know that their browser stinks. :)

Paul Prewett
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top