Home Web Front-end JS Tutorial How does jquery determine whether it is an IE browser?

How does jquery determine whether it is an IE browser?

Nov 24, 2020 pm 02:52 PM
ie browser jquery

Jquery method to determine whether it is an IE browser: You can use the jquery browser method to determine, such as [$.browser.msie]. If we still need to distinguish the version, we need to use [jQuery.browser.version 】method.

How does jquery determine whether it is an IE browser?

The operating environment of this tutorial: windows10 system, jquery3.2.1 version. This method is suitable for all brands of computers.

(Learning video sharing: javascript video tutorial)

Jquery method to determine whether it is an IE browser:

JQuery You can use the jQuery.browser method to determine the browser type. The return value can be: safari, opera, msie, mozilla. If the return value is msie, it means the browser is ie.

Of course sometimes we also need to distinguish versions, which requires the use of jQuery.browser.version.

Example:

function JudgeBroswer() {
        if($.browser.msie) {
            alert("this is msie!"); //IE        }
        else if($.browser.safari)
        {
            alert("this is safari!"); //Safari         }
        else if($.browser.mozilla)
        {
            alert("this is mozilla!");  //Firefox        }
        else if($.browser.opera) {
            alert("this is opera");     //Opera        }
    }
Copy after login

jquery source code:

var userAgent = navigator.userAgent.toLowerCase();   
// Figure out what browser is being used
   jQuery.browser = {
    version: (userAgent.match(/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/) || [])[1],
    safari: /webkit/.test(userAgent),
    opera: /opera/.test(userAgent),
    msie: /msie/.test(userAgent) && !/opera/.test(userAgent),
    mozilla:/mozilla/.test(userAgent)&&!/(compatible|webkit)/.test(userAgent)
    };
Copy after login

Related recommendations: js tutorial

The above is the detailed content of How does jquery determine whether it is an IE browser?. For more information, please follow other related articles on the PHP Chinese website!

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

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

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)

What should I do if the images on the webpage cannot be loaded? 6 solutions What should I do if the images on the webpage cannot be loaded? 6 solutions Mar 15, 2024 am 10:30 AM

Some netizens found that when they opened the browser web page, the pictures on the web page could not be loaded for a long time. What happened? I checked that the network is normal, so where is the problem? The editor below will introduce to you six solutions to the problem that web page images cannot be loaded. Web page images cannot be loaded: 1. Internet speed problem The web page cannot display images. It may be because the computer's Internet speed is relatively slow and there are more softwares opened on the computer. And the images we access are relatively large, which may be due to loading timeout. As a result, the picture cannot be displayed. You can turn off the software that consumes more network speed. You can go to the task manager to check. 2. Too many visitors. If the webpage cannot display pictures, it may be because the webpages we visited were visited at the same time.

How to set up trusted sites in win11_How to add trusted sites in IE in windows11 How to set up trusted sites in win11_How to add trusted sites in IE in windows11 May 08, 2024 pm 01:11 PM

1. First, we open the IE browser in our system, find the gear-shaped button in the upper right corner, and click it. 2. After clicking it, you will see a drop-down menu, find and click [Compatibility View Settings] 4. Then enter the URL that needs to be added in Add this website, and then click [Add] on the right.

jQuery Tips: Quickly modify the text of all a tags on the page jQuery Tips: Quickly modify the text of all a tags on the page Feb 28, 2024 pm 09:06 PM

Title: jQuery Tips: Quickly modify the text of all a tags on the page In web development, we often need to modify and operate elements on the page. When using jQuery, sometimes you need to modify the text content of all a tags in the page at once, which can save time and energy. The following will introduce how to use jQuery to quickly modify the text of all a tags on the page, and give specific code examples. First, we need to introduce the jQuery library file and ensure that the following code is introduced into the page: &lt

Use jQuery to modify the text content of all a tags Use jQuery to modify the text content of all a tags Feb 28, 2024 pm 05:42 PM

Title: Use jQuery to modify the text content of all a tags. jQuery is a popular JavaScript library that is widely used to handle DOM operations. In web development, we often encounter the need to modify the text content of the link tag (a tag) on ​​the page. This article will explain how to use jQuery to achieve this goal, and provide specific code examples. First, we need to introduce the jQuery library into the page. Add the following code in the HTML file:

How to turn off ads in edge browser? Introduction to how to turn off ads in edge browser How to turn off ads in edge browser? Introduction to how to turn off ads in edge browser Mar 14, 2024 pm 03:49 PM

The edge browser is now a browser tool installed on Windows systems. Many users find that many advertising pop-ups appear when using it. Many people want to know how to set up these advertisements to close them. In response to this problem, Today's Software The tutorial is here to answer the questions for the majority of users. Next, let us take a look at the detailed steps. Introduction to how to turn off edge browser ads: 1. Enter the software, click the three-dot icon on the right side of the top of the page, and select "Settings" in the drop-down option menu. 2. In the new interface, click "Advanced" and then find "Use" under "Website Settings"

How to cancel the automatic jump to Edge when opening IE in Win10_Solution to the automatic jump of IE browser page How to cancel the automatic jump to Edge when opening IE in Win10_Solution to the automatic jump of IE browser page Mar 20, 2024 pm 09:21 PM

Recently, many win10 users have found that their IE browser always automatically jumps to the edge browser when using computer browsers. So how to turn off the automatic jump to edge when opening IE in win10? Let this site carefully introduce to users how to automatically jump to edge and close when opening IE in win10. 1. We log in to the edge browser, click... in the upper right corner, and look for the drop-down settings option. 2. After we enter the settings, click Default Browser in the left column. 3. Finally, in the compatibility, we check the box to not allow the website to be reloaded in IE mode and restart the IE browser.

How to set compatibility mode in edge browser? Where to set edge browser compatibility settings? How to set compatibility mode in edge browser? Where to set edge browser compatibility settings? Apr 15, 2024 pm 02:46 PM

The edge browser is a browser software that many users like to use. It has a simple interface but complete functions. Some novices want to set the compatibility mode for the new version of the edge browser. How do they do it? This tutorial will give you detailed operation tutorials, I hope it will be useful to everyone. Edge browser compatibility mode setting 1. Click the start menu in the lower left corner of the computer and select Microsoft Edge browser. 2. After opening the Edge browser, click the “…” icon in the upper right corner. 3. Click the "Open with Internet Explorer" option in the pop-up options. 4. Open IE to browse

How to tell if a jQuery element has a specific attribute? How to tell if a jQuery element has a specific attribute? Feb 29, 2024 am 09:03 AM

How to tell if a jQuery element has a specific attribute? When using jQuery to operate DOM elements, you often encounter situations where you need to determine whether an element has a specific attribute. In this case, we can easily implement this function with the help of the methods provided by jQuery. The following will introduce two commonly used methods to determine whether a jQuery element has specific attributes, and attach specific code examples. Method 1: Use the attr() method and typeof operator // to determine whether the element has a specific attribute

See all articles