Home  >  Article  >  Web Front-end  >  How jquery determines whether the browser is ie

How jquery determines whether the browser is ie

coldplay.xixi
coldplay.xixiOriginal
2020-11-17 13:44:362461browse

The jquery method to determine whether the browser is IE: first create a new file and create a click button; then use the judgment statement [if (window.ActiveXObject || "ActiveXObject" in window)].

How jquery determines whether the browser is ie

Recommendation: "jquery video tutorial"

Jquery method to determine whether the browser is ie:

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

Code:

<input type="button" onclick="test()" value="判断浏览器" />

How jquery determines whether the browser is ie

2. Determine 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 picture:

Code:

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

How jquery determines whether the browser is ie

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

Related free learning recommendations: JavaScript(Video)

The above is the detailed content of How jquery determines whether the browser is ie. 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