判斷各瀏覽器
阿新 • • 發佈:2017-11-16
window rod his fine selector ati request tel quest
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; }
判斷各瀏覽器