tags:

views:

73

answers:

2

How do I verify if a site has Javascript enabled and if user's browser is IE 8?

+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
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
nice tip, but probably a bit over the top?
nickf
Indeed @nickf, I don't know about 'have to' :)
thenduks
Thanks for pointing that out...
kennebec