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

How does jquery determine whether it is an IE browser?

藏色散人
藏色散人Original
2020-11-23 11:27:042462browse

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>

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!

Statement:
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