oops variable s has been not defined but still it will not make any
difference!!!
-----Original Message-----
From: Vijay Kumar Patil
Sent: 04 July 2000 15:57
To: javascript
Subject: [javascript] RE: Detecting which browser is viewing your page
well if you want to just find out the type of browser you are using you can
use this code.
var ns = document.layers ? true:false;
var ie = document.all ? true :false;
there is no error in this code but there is a silly thing you are doing
here. document.write, you can not use this when want to show the browser
properties.
i think you will find your solution in this code:
this code is working fine and has been tested under IE 5.0 NS4.0
/*
<HTML>
<HEAD>
<TITLE>DETECTING THE BROWSER</TITLE>
<SCRIPT LANGUAGE="javascript">
alert (navigator.appName);
function displayNavigatorProperties() {
s = "<b>Appname : </b>" + navigator.appName + "<br>" + "<B>User Agent :
</b>" + navigator.userAgent + "<Br>"
document.write(s);
}
function displayExplorerProperties() {
s = "<b>Appname : </b>" + navigator.appName + "<br>" + "<B>User Agent :
</b>" + navigator.userAgent + "<Br>"
document.write(s);
}
function displayBrowserProperties() {
if(window.navigator.appName=="Netscape")
displayNavigatorProperties();
else
if(window.navigator.appName=="Microsoft Internet Explorer")
displayExplorerProperties();
}
displayBrowserProperties();
</SCRIPT>
</HEAD>
<BODY>
</BODY>
</HTML>
*/
cheers,
vijay
-----Original Message-----
From: Alan [mailto:alanhughesy@a...]
Sent: 04 July 2000 13:54
To: javascript
Subject: [javascript] Detecting which browser is viewing your page
I am using the following script to determine the browser vviewing my page
however when it is run it Netscape or IE it returns 'undefined' for both
properties. I am not a frequent Javascript user but I do need this piece
of code to work for obvious reasons, can anyone spot what I'm doing wrong?
ps: the comments (/* */) are not included in the code on the page that runs
this code only here in case the html is interpreted.
/*
<HTML>
<HEAD>
<TITLE>DETECTING THE BROWSER</TITLE>
<SCRIPT LANGUAGE="JAVASCRIPT">
function displayNavigatorProperties() {
with(document) {
write("<B>appname: </B>")
write(navigator.appname+"</BR>")
write("<B>useragent: </B>")
write(navigator.useragent+"</BR>")
}
}
function displayExplorerProperties() {
with(document) {
write("<B>appname: </B>")
writeln(navigator.appname+"</BR>")
write("<B>useragent: </B>")
write(navigator.useragent+"</BR>")
}
}
function displayBrowserProperties() {
if(navigator.appName=="Netscape")
displayNavigatorProperties()
else
if(navigator.appName=="Microsoft Internet Explorer")
displayExplorerProperties()
}
displayBrowserProperties()
</SCRIPT>
</HEAD>
<BODY>
</BODY>
</HTML>
*/