一种判断浏览器版本的步骤
一种判断浏览器版本的方法
一种判断浏览器版本的方法
主要通过ie浏览器的条件注释来实现
<!DOCTYPE html> <!--[if IE 6]> <html class="ie6" lang="zh-cmn-Hans"><![endif]--> <!--[if IE 7]> <html class="ie7" lang="zh-cmn-Hans"><![endif]--> <!--[if IE 8]> <html class="ie8" lang="zh-cmn-Hans"><![endif]--> <!--[if IE 9]> <html class="ie9" lang="zh-cmn-Hans"><![endif]--> <!--[if !IE]><!--> <html lang="zh-cmn-Hans"> <script> if (window.navigator.userAgent.toLowerCase().indexOf("firefox") >= 0) { document.documentElement.className += ' firefox'; } else if (window.navigator.userAgent.toUpperCase().indexOf("chrome") >= 0) { document.documentElement.className += ' chrome'; } else { if (/*@cc_on!@*/false) {//ie10 document.documentElement.className += ' ie10'; } if (document.documentMode) { if (/*@cc_on!@*/true) {//ie11 document.documentElement.className += ' ie' + document.documentMode; } } } </script> <!--<![endif]-->
然后css就可以这么写
.ie6 body{ /*ie6 hack*/ } .ie7 body{ /*ie7 hack*/ }