最近的网站项目当中用上了vue,结果ie低版本的不支持es5的写法,导致各种报错,而且一些很实用的api也不能用了..还有webGL的支持也是让人心碎,于是乎就有了下面的一段代码

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
$uarowser=$_SERVER['HTTP_USER_AGENT'];

if(strstr($uarowser, 'MSIE 6') || strstr($uarowser, 'MSIE 7') || strstr($uarowser, 'MSIE 8')){
echo '
<div id="ie-alertBox">
<div id="ie-infoBar"><h1>对不起,本站不支持低版本ie浏览器!</h1><p>请使用ie9或更高的版本</p><p>试试火狐啊谷歌什么的超好用的,如果你对IE是真爱......那么请关闭本站吧。</p></div>
</div>
<div id="ie-overlay"></div>
<style type="text/css">
#ie-alertBox{width: 600px;margin-top: 160px;margin-right: auto;margin-bottom: 0px;margin-left: auto;padding: 20px;border: 1px solid #CCCCCC;text-align: center;font-family: "Microsoft YaHei", Verdana, sans-serif; line-height: 30px;} #ie-infoBar h1{font-size: 22px;color: #ff0000;line-height: 60px;}
</style>
';
exit;
}

当使用万恶的ie的时候可以加上下面段

1
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

优先使用chrome渲染,如果碰到ie就用浏览器支持的最高版本