使用jQuery识别IE9 / IE10 [英] Identify IE9/IE10 using jQuery
本文介绍了使用jQuery识别IE9 / IE10的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个适用于Chrome / Mozilla而不是IE的jQuery代码。
I have a jQuery code which is working fine for Chrome/Mozilla but not IE.
if ($("html").hasClass("ie")) {
$(function(){
$('.green-column, .red-column, .grey-column').click(function() {
alert ($(this).attr("data-type"));
});
});
}
else {
$(function(){
$('.green-column, .red-column, .grey-column').click(function() {
$("<div title='Selected Task is:'>" + $(this).attr("data-type") + "</div>").dialog({
modal: true,
resizable: false,
buttons: [
{
text: "OK",
click: function() { $( this ).dialog( "close" ); }
}
]
});
});
});
}
</script>
<!--[if IE 7]> <html lang="en-us" class="ie"> <![endif]-->
<!--[if IE 8]> <html lang="en-us" class="ie"> <![endif]-->
<!--[if gt IE 8]><!--> <html lang="en-us" class="ie"> <!--<![endif]-->
所以我打算为IE9 / IE10使用警报,但我无法区分浏览器。任何人都可以告诉我如何识别jQuery / HTML中的IE9 / IE10?
So I plan to use an alert for IE9/IE10 but I am not able to differentiate between the browsers. Can anyone tell me how to identify IE9/IE10 in jQuery/HTML?
推荐答案
无需使用库或条件编译即可实现:
Can be achieved without using libraries or conditional compilation:
if (document.addEventListener) {
alert("IE9 or greater");
}
if (window.requestAnimationFrame) {
alert("IE10 or greater");
}
这篇关于使用jQuery识别IE9 / IE10的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文