javascripthtmlinternet-exploreralertietester

Javascript not working on specific versions of IE


I've a rare issue with IE. I'm trying to create a page that launches this script when IE version is lower or equal than IE 8 (just a simple alert and a location). When I try to debug this html on IETester the alert only shows up on IE 5.5 and IE 6 but neither in 7 nor 8. What am I doing wrong?

<!DOCTYPE html>
<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<!--[if lte IE 8]>
    <script type="text/javascript">
        alert('Para poder usar Consumedia necesita tener instalada una version de Internet Explorer 9 o superior');
        window.location = "http://www.google.com";
    </script>   
<![endif]-->
</head>
<body>
</body>
</html>

Solution

  • This is showing me the alert with native IE7.

    It seems IETester might have a bug regarding conditional comments. See How do I make IE9 emulate IE7? for an alternative to IETester.

    @Pekka has already commented on this matter a couple of times:

    When multiple instances of Internet Explorer are installed (or active) on the same system, conditional comments will be resolved against the highest IE version available on the system

    EDIT: Doesn't really add much, but I've got only IE7 installed, and it also shows the alert with IETester for IE <= 7.