How do I verifying if site has javascript enabled and if user's browser is IE 8
How do I verify if a site has Javascrip开发者_如何学Ct enabled and if user's browser is IE 8?
Use conditional comments and some javascript code (it will work only if it's enabled, right? :))
<!--[if IE 8]>
<script type="text/javascript"> /*do something in JS - it's enabled!*/ </script>
<[endif]-->
Or you may want to look at conditional compilation in JS
If for whatever reason you need to know that you are dealing with IE8,
you have to watch for the IE9 preview, which smells like IE8, but has some new objects:
<!--[if IE 8]>
<script type="text/javascript">
if(document.addEventListener) alert('IE9');
if(document.documentMode) alert('IE8'+ running as '+document.documentMode);
</script>
<[endif]-->
精彩评论