javascript通过navigator.userAgent识别各种浏览器

 

参考链接:

 

http://www.jb51.net/article/42415.htm

 

http://fp-moon.iteye.com/blog/1142629

 

// IE Check
  if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)) {
    var rv = -1;
    var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
    if (re.exec(navigator.userAgent) != null) {
      rv = parseFloat(RegExp.$1);
    }
    if (rv < 8) {
     // window.location = '/browser/upgrade.html';
    } // else if ( 9 <= rv && rv < 10 ) {
    // sendMessage('为了得到更好的MYSTU体验,请<a href="/browser/upgrade.html"
    // style="color:white;">升级或换用浏览器</a>。');
    // }

  }

 

posted @ 2016-06-03 09:54  linyongqin  阅读(171)  评论(0)    收藏  举报