[Javascript] Mac Sniffer
Muchacho, Laurent (TWIi London)
LMuchacho at twii.net
Mon Jan 7 05:28:23 CST 2002
Hi there it is
d = document;
function brow(){
this.ie = (d.all)? true:false;
this.ns = (d.layers)? true:false;
this.ns6 = (d.getElementById&&!document.all)? true:false
this.mac = (navigator.appVersion.indexOf("Mac")!=-1)? true:false;
this.win = (navigator.appVersion.indexOf("win")!=-1)? true:false;
}
var bw = new brow()
if (bw.mac){
alert('this is a mac (bad)')
if (bw.ie){
alert('ie true')
}
}
if (bw.win){
alert('this is a PC running window (good)')
if (bw.ie){
alert('ie true')
}
}
or that will work too with any combinaison
if (bw.mac&&bw.ie){
alert('this is a mac (bad) running ie (even badder)')
}
Laurent
-----Original Message-----
From: Tom Churm [mailto:thomas.churm at pixelpark.com]
Sent: 07 January 2002 11:03
To: javascript at LaTech.edu
Subject: [Javascript] Mac Sniffer
hi,
it's important that i find & implement a highly reliable Mac Sniffer
and i found/adapted the following code from Netscape's "Ultimate
JavaScript Client Sniffer" here:
http://www.mozilla.org/docs/web-developer/sniffer/browser_type.html
could someone please tell me if this incredibly simple code will
suffice in sniffing out all of the various incarnations of Mac
operating systems out there? (code follows)
<SCRIPT TYPE="text/javascript" LANGUAGE="JavaScript">
<!--
var agt=navigator.userAgent.toLowerCase();
var is_mac = (agt.indexOf("mac")!=-1);
if (agt.indexOf("mac")!=-1) {
window.location.href = "for_mac.html";
}
else {
window.location.href = "for_pc.html";
}
//-->
</SCRIPT>
it seems to work--it's just that i don't have a lot of different Macs
at my disposal to test this on.
muchos gracias,
tom
_______________________________________________
Javascript mailing list
Javascript at LaTech.edu
https://lists.LaTech.edu/mailman/listinfo/javascript
More information about the Javascript
mailing list