Home > Article > Web Front-end > How jquery determines whether the browser is ie
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)].
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="判断浏览器" />
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>
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!