如果浏览器低于IE9,我想在jQuery中执行某些代码。是的,我已经知道
<!--[if ... IE ]> <![endif]-->但是我想要的是在scipt标记中使用jQuery document.ready检查这个条件。
<script>
$(document).ready(function(){
//code to check if lt ie9
});
</script>发布于 2013-08-09 19:46:06
您可以通过<html>元素上的类来瞄准较旧的Internet Explorer版本(<= 9) ...
<!--[if lt IE 7]> <html class="ie ie6 lte9 lte8 lte7"> <![endif]-->
<!--[if IE 7]> <html class="ie ie7 lte9 lte8 lte7"> <![endif]-->
<!--[if IE 8]> <html class="ie ie8 lte9 lte8"> <![endif]-->
<!--[if IE 9]> <html class="ie ie9 lte9"> <![endif]-->
<!--[if gt IE 9]> <html> <![endif]-->
<!--[if !IE]><!--> <html> <!--<![endif]-->..。然后检查<html>是否具有类.lt9或.lt8 -无论您针对的是哪种版本的Internet Explorer:
if($('html').hasClass('lte9')) { /* LTE IE9 */ }但是,我建议使用Modernizr功能检测,而不是检查特定的浏览器。
发布于 2013-08-09 19:51:14
使用功能检测而不是浏览器检测。即http://modernizr.com/
https://stackoverflow.com/questions/18145816
复制相似问题