【发布时间】:2013-03-17 11:03:59
【问题描述】:
我有一个适用于 Chrome/Mozilla 但不适用于 IE 的 jQuery 代码。
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?
【问题讨论】:
-
在浏览器之间进行区分或拒绝浏览器的访问都不好。 JQuery 应该适用于 IE 9 和 10,因此您的 HTML 或 CSS 代码可能存在故障。尝试解决这个问题,不要使用浏览器嗅探。
-
如果你有一个只出现在特定浏览器中的渲染错误,并且修复它的唯一方法是将slideUp() 更改为hide()。仅适用于某些浏览器...
标签: jquery html internet-explorer browser-detection