Home Web Front-end JS Tutorial js multiple browsers judge code separately_javascript skills

js multiple browsers judge code separately_javascript skills

May 16, 2016 pm 06:30 PM
Browser

复制代码 代码如下:

/* 浏览器判断 */
var userAgent = navigator.userAgent.toLowerCase();
var is_webtv = userAgent.indexOf('webtv') != -1;
var is_kon = userAgent.indexOf('konqueror') != -1;
var is_mac = userAgent.indexOf('mac') != -1;
var is_saf = userAgent.indexOf('applewebkit') != -1 || navigator.vendor == 'Apple Computer, Inc.';
var is_opera = userAgent.indexOf('opera') != -1 && opera.version();
var is_moz = (navigator.product == 'Gecko' && !is_saf) && userAgent.substr(userAgent.indexOf('firefox') 8, 3);
var is_ns = userAgent.indexOf('compatible') == -1 && userAgent.indexOf('mozilla') != -1 && !is_opera && !is_webtv && !is_saf;
var is_ie = (userAgent.indexOf('msie') != -1 && !is_opera && !is_saf && !is_webtv) && userAgent.substr(userAgent.indexOf('msie') 5, 3);
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

Repo: How To Revive Teammates
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to solve the problem of third-party interface returning 403 in Node.js environment? How to solve the problem of third-party interface returning 403 in Node.js environment? Mar 31, 2025 pm 11:27 PM

Solve the problem of third-party interface returning 403 in Node.js environment. When we use Node.js to call third-party interfaces, we sometimes encounter an error of 403 from the interface returning 403...

gate.io latest registration tutorial for beginners gate.io latest registration tutorial for beginners Mar 31, 2025 pm 11:12 PM

This article provides newbies with detailed Gate.io registration tutorials, guiding them to gradually complete the registration process, including accessing the official website, filling in information, identity verification, etc., and emphasizes the security settings after registration. In addition, the article also mentioned other exchanges such as Binance, Ouyi and Sesame Open Door. It is recommended that novices choose the right platform according to their own needs, and remind readers that digital asset investment is risky and should invest rationally.

The latest registration tutorial for gate.io web version The latest registration tutorial for gate.io web version Mar 31, 2025 pm 11:15 PM

This article provides a detailed Gate.io web version latest registration tutorial to help users easily get started with digital asset trading. The tutorial covers every step from accessing the official website to completing registration, and emphasizes security settings after registration. The article also briefly introduces other trading platforms such as Binance, Ouyi and Sesame Open Door. It is recommended that users choose the right platform according to their own needs and pay attention to investment risks.

How to avoid being detected by the browser when using Fiddler Everywhere for man-in-the-middle reading? How to avoid being detected by the browser when using Fiddler Everywhere for man-in-the-middle reading? Apr 02, 2025 am 07:15 AM

How to avoid being detected when using FiddlerEverywhere for man-in-the-middle readings When you use FiddlerEverywhere...

How to implement cross-application jump for Word plug-in login authorization? How to implement cross-application jump for Word plug-in login authorization? Apr 01, 2025 pm 11:27 PM

How to implement cross-application jump for Word plug-in login authorization? When using certain Word plugins, we often encounter this scenario: click on the login in the plugin...

Jiutian Computing Power Platform Task: Will the computing task continue to run after the local computer is shut down? Jiutian Computing Power Platform Task: Will the computing task continue to run after the local computer is shut down? Apr 01, 2025 pm 11:57 PM

Discussion on the task status after the local computer of Jiutian Computing Power Platform is closed. Many users will encounter a question when using Jiutian Computing Power Platform for artificial intelligence training...

Why did the small window become blank after scanning the QR code on WeChat? How to solve it? Why did the small window become blank after scanning the QR code on WeChat? How to solve it? Apr 01, 2025 pm 03:54 PM

Handle the problem of blank small window after scanning the QR code on WeChat. When using WeChat to scan the QR code on WeChat, we often encounter some unexpected problems. A common...

What is the reason for redirecting 404 errors after logging in with Selenium? How to solve it? What is the reason for redirecting 404 errors after logging in with Selenium? How to solve it? Apr 01, 2025 pm 10:54 PM

Solution to Redirecting 404 Errors after Simulation Login When using Selenium for Simulation Login, we often encounter some difficult problems. �...

See all articles