一种判断浏览器版本的方法
主要通过ie浏览器的条件注释来实现
<!DOCTYPE html><!--[if IE 6]><html lang="zh-cmn-Hans"><![endif]--><!--[if IE 7]><html lang="zh-cmn-Hans"><![endif]--><!--[if IE 8]><html lang="zh-cmn-Hans"><![endif]--><!--[if IE 9]><html 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*/}
原标题:一种判断浏览器版本的方法
关键词:浏览器