码迷,mamicode.com
首页 > 其他好文 > 详细

判断各浏览器

时间:2017-11-16 15:51:27      阅读:132      评论:0      收藏:0      [点我收藏+]

标签:bsp   agent   rom   his   opera   chrome   http   判断   navig   

function Browser() {
    this.Opera = window.opera ? true : false;
    this.IE = document.all && !this.Opera ? true : false;
    this.IE6 = this.IE && typeof(window.XMLHttpRequest) == "undefined" ? true : false;
    this.IE8 = this.IE && typeof(document.querySelectorAll) != "undefined" ? true : false;
    this.IE7 = this.IE && !this.IE6 && !this.IE8 ? true : false;
    this.WebKit = /WebKit/i.test(navigator.userAgent) ? true : false,
        this.iPhone = /iPhone|iPod/i.test(navigator.userAgent) ? true : false;
    this.Chrome = /Chrome/i.test(navigator.userAgent) ? true : false;
    this.Safari = /Safari/i.test(navigator.userAgent) && !this.Chrome ? true : false;
    this.Konqueror = navigator.vendor == "KDE" ? true : false;
    this.Konqueror4 = this.Konqueror && /native code/.test(document.getElementsByClassName) ? true : false;
    this.Gecko = !this.WebKit && navigator.product == "Gecko" ? true : false;
    this.Gecko19 = this.Gecko && Array.reduce ? true : false;
    this.toString = "Opera=" + this.Opera + ",IE=" + this.IE + ",IE6=" + this.IE6 + ",IE7=" + this.IE7 + ",IE8=" + this.IE8 + ",Chrome=" + this.Chrome;
}

 

判断各浏览器

标签:bsp   agent   rom   his   opera   chrome   http   判断   navig   

原文地址:http://www.cnblogs.com/zxcc/p/7844618.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!