How do I verify if a site has Javascript enabled and if user's browser is IE 8?
views:
73answers:
2
+2
A:
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
pawel
2010-03-23 00:05:43
A:
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]-->
kennebec
2010-03-23 01:19:53
nice tip, but probably a bit over the top?
nickf
2010-03-23 01:23:06
Indeed @nickf, I don't know about 'have to' :)
thenduks
2010-03-23 01:42:53
Thanks for pointing that out...
kennebec
2010-03-23 05:40:04