The problem is that the navigate() method is specific to IE, Navigator just
ignores it. Fortunately the location object is used in both IE and
Navigator, so you can redirect the browser using this. To go to another
location just set the href property of the location object. i.e.
location.href = "http://www.hello.com"
or more simply,
location = "http://www.hello.com"
Trevor
-----Original Message-----
From: Alan [mailto:alanhughesy@a...]
Sent: 05 July 2000 02:17
To: javascript
Subject: [javascript] Tea Time Quickie - Browser Detection
I have written the following code and it works fine under IE 4.0 in other
words it checks the type of browser and if it is IE then it loads the page
www.hello.com.
However when thius code is run under a netscape browser it does not load
the microsoft page. I put the alert there to see if it was detecting the
browser and it is as the alert is shown.
Can anyone see where I'm going wrong?
<HTML>
<HEAD>
<TITLE>DETECTING THE BROWSER</TITLE>
<SCRIPT LANGUAGE="JAVASCRIPT">
function displayBrowserProperties() {
window.document.write("howareyou")
if(navigator.appName=="Microsoft Internet Explorer")
navigate("http://www.hello.com")
else
if(navigator.appName!=="Microsoft Internet Explorer")
alert("how")
navigate("http://www.microsoft.com")
}
displayBrowserProperties()
</SCRIPT
</HEAD>
<BODY>
</BODY>
</HTML>