网页特效 浏览器与操作系统类型
var browserdetect={
init: function (){
this.browser=this.searchstring(this.databrowser)||"an unknown browser";
this.version=this.searchversion(navigator.useragent)||this.searchversion(navigator.appversion)||"an unknown version";
this.os=this.searchstring(this.dataos)||"an unknown os";
},
searchstring: function (data){
for(var i=0;i<data.length;i++){
var datastring=data[i].string;
var dataprop=data[i].prop;
this.versionsearchstring=data[i].versionsearch||data[i].identity;
if(datastring){
if(datastring.indexof(data[i].substring)!=-1)
return data[i].identity;
}
else if(dataprop)
return data[i].identity;
}
},
searchversion: function (datastring){
var index=datastring.indexof(this.versionsearchstring);
if(index==-1) return;
return parsefloat(datastring.substring(index+this.versionsearchstring.length+1));
},
databrowser: [
{string: navigator.useragent,substring: "omniweb",versionsearch: "omniweb/",identity: "omniweb"},
{string: navigator.vendor,substring: "apple",identity: "safari"},
{prop: window.opera,identity: "opera"},
{string: navigator.vendor,substring: "icab",identity: "icab"},
{string: navigator.vendor,substring: "kde",identity: "konqueror"},
{string: navigator.useragent,substring: "firefox",identity: "firefox"},
{string: navigator.vendor,substring: "camino",identity: "camino"},
{string: navigator.useragent,substring: "netscape",identity: "netscape"},
{string: navigator.useragent,substring: "msie",identity: "explorer",versionsearch: "msie"},
{string: navigator.useragent,substring: "gecko",identity: "mozilla",versionsearch: "rv"},
{string: navigator.useragent,substring: "mozilla",identity: "netscape",versionsearch: "mozilla"}
],
dataos : [
{string: navigator.platform,substring: "win",identity: "windows"},
{string: navigator.platform,substring: "mac",identity: "mac"},
{string: navigator.platform,substring: "linux",identity: "linux"}
]
};
browserdetect.init();