【ie兼容】判断ie版本跳转到指定页面下载浏览器

//判断是否是ie且给出ie版本号
    function IEVersion() {
      var userAgent = navigator.userAgent; //取得浏览器的userAgent字符串
      var isIE = userAgent.indexOf("compatible") > -1 && userAgent.indexOf("MSIE") > -1; //判断是否IE<11浏览器
      var isEdge = userAgent.indexOf("Edge") > -1 && !isIE; //判断是否IE的Edge浏览器
      var isIE11 = userAgent.indexOf('Trident') > -1 && userAgent.indexOf("rv:11.0") > -1;
      if(isIE) {
        var reIE = new RegExp("MSIE (\\d+\\.\\d+);");
        reIE.test(userAgent);
        var fIEVersion = parseFloat(RegExp["$1"]);
        if(fIEVersion == 7) {
          return 7;
        } else if(fIEVersion == 8) {
          return 8;
        } else if(fIEVersion == 9) {
          return 9;
        } else if(fIEVersion == 10) {
          return 10;
        } else {
          return 6;//IE版本<=7
        }
      } else if(isEdge) {
        return 'edge';//edge
      } else if(isIE11) {
        return 11; //IE11
      }else{
        return -1;//不是ie浏览器
      }
    }
var isIE = IEVersion();
// alert(isIE)
if (isIE == "6" || isIE == "7" || isIE == "8" || isIE == "9" ){
    window.location = "/browser.html";
}

browser.html


<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>请升级浏览器</title>
</head>
<body>
<style>
    html{
        width:100%;
        height:100%;
    }
    body{
        margin:0px;
    }
    h2{
        margin:0px;
        padding: 30px;
    }
    a{
        display: block;
        text-align: center;
        text-decoration: none;
    }
    h2{
        color: #ffffff;
        text-align: center;
    }
    .serf{
        width:1000px;
        min-height:10px;
        overflow: hidden;
        margin: 0 auto;
    }
    ul,li{
        list-style: none;
    }
    li{
        color: #ffffff;
        float: left;
        width:25%;
    }
    p{
        color: #ffffff;
    }
    img{
        text-align: center;
        width:80px;
        height:80px;
    }
    #bg{
        width:100%;
        height: 100%;
        position: fixed;
        z-index: -1;
    }

</style>
<img id="bg" src="https://p.ssl.qhimg.com/t01fe359f246f9e7ec6.jpg" alt="">
<h2>您的浏览器版本过低,建议您更新浏览器或下载其他浏览器</h2>
<h2>推荐谷歌浏览器体验更佳</h2>
<div class="serf">
    <ul>
        <li>
            <a href="https://pc.qq.com/detail/1/detail_2661.html" target="_blank">
                <img src="https://pc3.gtimg.com/softmgr/logo/48/2661_48_1450768944.png" alt="">
                <p>谷歌浏览器</p>
            </a>
        </li>
        <li>
            <a href="http://www.firefox.com.cn/" target="_blank">
                <img src="https://pc3.gtimg.com/softmgr/logo/48/2867_48_1510709737.png" alt="">
                <p>火狐浏览器</p>
            </a>
        </li>
		
		<li>
            <a href="https://www.opera.com/zh-cn" target="_blank">
                <img src="https://pc3.gtimg.com/softmgr/logo/48/314_48_1401845457.png" alt="">
                <p>opear浏览器</p>
            </a>
        </li>
		<li>
            <a href="http://se.360.cn/xp.html" target="_blank">
                <img src="https://p1.ssl.qhmsg.com/d/_open360/logo72nb/100923_72.png" alt="">
                <p>360浏览器-XP系统专版</p>
            </a>
        </li>
        
        
    </ul>
	<ul>
		<li>
            <a href="http://www.maxthon.cn/" target="_blank">
                <img src="https://img.sandbox.qixinyun.com/aoyou-icon.png" alt="">
                <p>遨游浏览器</p>
            </a>
        </li>
		<li>
            <a href="https://browser.360.cn/ee/" target="_blank">
                <img src="https://browser.360.cn/ee/favicon.ico" alt="">
                <p>360极速浏览器</p>
            </a>
        </li>
        <li>
            <a href="https://browser.qq.com/?adtag=SEM170314020" target="_blank">
                <img src="https://pc3.gtimg.com/softmgr/logo/48/13411_48_1505200425.png" alt="">
                <p>QQ浏览器</p>
            </a>
        </li>
		<li>
            <a href="https://pc.qq.com/detail/13/detail_13993.html" target="_blank">
                <img src="https://pc3.gtimg.com/softmgr/logo/48/13993_48_1397110476.png" alt="">
                <p>UC浏览器</p>
            </a>
        </li>
    </ul>

</div>

</body>
</html>

发布了110 篇原创文章 · 获赞 36 · 访问量 13万+

猜你喜欢

转载自blog.csdn.net/wjx_jasin/article/details/100738575