これができるとイロイロと便利です。
<script type="text/javascript"> $(function(){ var _ua = (function(){ return { ltIE6:typeof window.addEventListener == "undefined" && typeof document.documentElement.style.maxHeight == "undefined", ltIE7:typeof window.addEventListener == "undefined" && typeof document.querySelectorAll == "undefined", ltIE8:typeof window.addEventListener == "undefined" && typeof document.getElementsByClassName == "undefined", ltIE9:document.uniqueID && !window.matchMedia, gtIE10:document.uniqueID && document.documentMode >= 10, Trident:document.uniqueID, Gecko:'MozAppearance' in document.documentElement.style, Presto:window.opera, Blink:window.chrome, Webkit:!window.chrome && 'WebkitAppearance' in document.documentElement.style, Touch:typeof document.ontouchstart != "undefined", Mobile:typeof window.orientation != "undefined", Pointer:window.navigator.pointerEnabled, MSPoniter:window.navigator.msPointerEnabled } })(); function require(src){ var element=document.createElement('script'); element.type='text/javascript'; element.src=src; document.getElementsByTagName('head')[0].appendChild(element); } if(_ua.ltIE8 || _ua.Gecko || _ua.Webkit){ $('#wrapper').css("background","#000000"); require('js/sample_ie.js'); }else{ require('js/sample.js'); } }); </script>
参考ページ
https://w3g.jp/blog/tools/js_browser_sniffing
http://detail.chiebukuro.yahoo.co.jp/qa/question_detail/q1161871241