<!--[if lt IE 7]>
<script type="text/javascript">
alert('请您升级到IE7或以上版本!')
window.open("http://www.baidu.com/search/theie6countdown.html","_self")
</script>
<![endif]-->
</head>
放到head里
使用ua判断,
function getBrowser() {var sys = {}
var ua = navigator.userAgent.toLowerCase()
var s
(s = ua.match(/edge\/([\d.]+)/)) ? sys.edge = s[1] :
(s = ua.match(/rv:([\d.]+)\) like gecko/)) ? sys.ie = s[1] :
(s = ua.match(/msie ([\d.]+)/)) ? sys.ie = s[1] :
(s = ua.match(/firefox\/([\d.]+)/)) ? sys.firefox = s[1] :
(s = ua.match(/chrome\/([\d.]+)/)) ? sys.chrome = s[1] :
(s = ua.match(/opera.([\d.]+)/)) ? sys.opera = s[1] :
(s = ua.match(/version\/([\d.]+).*safari/)) ? sys.safari = s[1] : 0
if (sys.edge) return {BrowserType: "Edge", version: sys.edge}
if (sys.ie) return {BrowserType: "IE", version: sys.ie}
if (sys.firefox) return {BrowserType: "Firefox", version: sys.firefox}
if (sys.chrome) return {BrowserType: "Chrome", version: sys.chrome}
if (sys.opera) return {BrowserType: "Opera", version: sys.opera}
if (sys.safari) return {BrowserType: "Safari", version: sys.safari}
return {BrowserType: "N/A", version: "0"}
}
在第二段中的代码为主要的H5支持版本,这里可以直接改成判断IE<10的版本:
if (browserType === "IE" && version < 10) {document.innerHTML = "请升级Internet Explore"//覆盖所有内容
}