Home > Web Front-end > JS Tutorial > JavaScript browser verification code (from discuz)_Basic knowledge

JavaScript browser verification code (from discuz)_Basic knowledge

WBOY
Release: 2016-05-16 18:22:50
Original
1303 people have browsed it

When looking at the source code of Discuz!, I found a piece of browser verification code, which is quite classic:

Copy code Code As follows:

var BROWSER = {};
var USERAGENT = navigator.userAgent.toLowerCase();
alert(USERAGENT);
BROWSER.ie = window.ActiveXObject && USERAGENT.indexOf('msie') != -1 && USERAGENT.substr(USERAGENT.indexOf('msie') 5, 3);
BROWSER.firefox = document.getBoxObjectFor && USERAGENT.indexOf('firefox') ! = -1 && USERAGENT.substr(USERAGENT.indexOf('firefox') 8, 3);
BROWSER.chrome = window.MessageEvent && !document.getBoxObjectFor && USERAGENT.indexOf('chrome') != -1 && USERAGENT.substr(USERAGENT.indexOf('chrome') 7, 10);
BROWSER.opera = window.opera && opera.version();
BROWSER.safari = window.openDatabase && USERAGENT.indexOf(' safari') != -1 && USERAGENT.substr(USERAGENT.indexOf('safari') 7, 8);
BROWSER.other = !BROWSER.ie && !BROWSER.firefox && !BROWSER.chrome && !BROWSER. opera && !BROWSER.safari;
BROWSER.firefox = BROWSER.chrome ? 1 : BROWSER.firefox;
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template