浏览器版本过低判断

来源:互联网 发布:linux守护进程编写 编辑:程序博客网 时间:2024/05/01 08:17
(function (window) {   function getBrowserInfo () {    var agent = navigator.userAgent.toLowerCase()    var regStrff = /firefox\/[\d.]+/gi    if (agent.indexOf('firefox') > 0) {      return agent.match(regStrff)    }  }  var browser = getBrowserInfo()  var verinfo = (browser + '').replace(/[^0-9.]/ig, '')  var theUA = window.navigator.userAgent.toLowerCase()  if ((theUA.match(/msie\s\d+/) && theUA.match(/msie\s\d+/)[0]) || (theUA.match(/trident\s?\d+/) && theUA.match(/trident\s?\d+/)[0])) {    var ieVersion = theUA.match(/msie\s\d+/)[0].match(/\d+/)[0] || theUA.match(/trident\s?\d+/)[0]    if (ieVersion < 9 || verinfo < '56') {      var str = '你的浏览器版本太low,已经和时代脱轨了 :( '      var str2 = "推荐使用:<a href='https://www.baidu.com/s?ie=UTF-8&wd=%E8%B0%B7%E6%AD%8C%E6%B5%8F%E8%A7%88%E5%99%A8' target='_blank' style='color:blue;'>谷歌</a>"      document.writeln("<pre style='text-align:center;color:#fff;background-color:#0cc; height:100%;border:0;position:fixed;top:0;left:0;width:100%;z-index:1234'>" +        "<h2 style='padding-top:200px;margin:0'><strong>" + str + '<br/></strong></h2><h2>' + str2 + '</h2></pre>')      document.execCommand('Stop')    }  }}(window))
阅读全文
0 0