答案 0 :(得分:0)
使用JS检查
function checkIE()
{
var ieVr = -1;
if (navigator.appName == 'Microsoft Internet Explorer')
{
var agent = navigator.userAgent;
var exp = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
if (exp.exec(agent) != null)
ieVr = parseFloat(RegExp.$1);
}
else if (navigator.appName == 'Netscape')
{
var agent = navigator.userAgent;
var exp = new RegExp("Trident/.*ieVr:([0-9]{1,}[\.0-9]{0,})");
if (exp.exec(agent) != null)
ieVr = parseFloat(RegExp.$1);
}
return ieVr;
}
根据PHP中的Doug
preg_match('/MSIE (.*?);/', $_SERVER['HTTP_USER_AGENT'], $matches);
if(count($matches)<2){
preg_match('/Trident\/\d{1,2}.\d{1,2}; rv:([0-9]*)/', $_SERVER['HTTP_USER_AGENT'], $matches);
}
if (count($matches)>1){
//Then we're using IE
$version = $matches[1];
switch(true)
{
case ($version<=8):
//IE 8 or under!
break;
case ($version==9 || $version==10):
//IE9 & IE10!
break;
case ($version==11):
//Version 11!
break;
default:
//You get the idea
}
}