JS浏览器特征检测
浏览器检测一般都用UserAgent来判别吗?有没有用一些浏览器特有的特征来检测的,比如
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Borser Detection</title>
<script type="text/javascript">
function selfUserAgent(){
if(window.ActiveXObject){ //MSIE 6.0 or below
//判断是否是IE 7以上
if(document.documentElement && typeof document.documentElement.style.maxHeight != "undefined" ){
//判断是否是IE8+
if(typeof document.adoptNode != "undefined"){//Safari3 & FF & Opera & Chrome & IE8+
return "IE8及以上";
}
return "IE7及以上";
}
return "MSIE 6.0 or below";
}else if(typeof window.opera != "undefined"){ //Opera 独占
return "Opera";
}else if(typeof window.netscape != "undefined"){ //mozilla 独占
if(typeof window.Iterator != "undefined"){
if(typeof document.styleSheetSets != "undefined"){//Firefox &Opera 9
return "firefox 3及以上";
}
return "firefox 2";
} <