Home > Web Front-end > JS Tutorial > body text

How does jquery determine whether it is an IE browser?

藏色散人
Release: 2020-11-30 10:06:06
Original
2523 people have browsed it

The method for jquery to determine whether it is an IE browser: first create a new HTML file; then create a click button to determine the browser type; finally pass "if (window.ActiveXObject || "ActiveXObject" in window" Method to judge.

How does jquery determine whether it is an IE browser?

The operating environment of this tutorial: windows7 system, jquery1.10.0 version, this method is suitable for all brands of computers.

Recommended : "jquery video tutorial"

  • This method is suitable for all brands of computers.

jquery determines whether it is an ie browser method

Create a new html file, and then create a click button to determine the browser type. As shown in the figure:

Code:

How does jquery determine whether it is an IE browser?

Judge whether the browser is IE browser. Use if (window.ActiveXObject || "ActiveXObject" in window) This line of code determines the type of browser. If it is an IE browser, it returns true, otherwise it returns false. In the case, an alert pop-up box will pop up to show whether it is an IE browser. As shown in the figure:

Code:

<script>
function test(){
if (window.ActiveXObject || "ActiveXObject" in window){
alert("ie")
}else{
alert("not ie")
}
}
</script>
Copy after login

How does jquery determine whether it is an IE browser?

After saving the html file, open it with IE browser. Click the browser button to find the content of the alert pop-up box. For: ie, when using other browsers to open the click button, the background prompt box displays: not ie.

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!

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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!