1

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>
frikkio
  • 93
  • 2
  • 10

2 Answers2

1

Sory for my first answer, a don't realize the real problem.

Try to change the if statement:

<!--[if lt IE 9]>
    //Fires for IE8 and above
<![endif]-->

See the examples here: http://css-tricks.com/how-to-create-an-ie-only-stylesheet/

red_alert
  • 1,738
  • 14
  • 24
  • windows.location = "http://www.google.com"; should also works then why there us a need for href – NetStarter Feb 21 '13 at 11:35
  • That's not the issue. I tried to comment this line and the alert doesn't show up. Thanks anyway ;) – frikkio Feb 21 '13 at 11:39
  • This has nothing to do with the problem though. The `alert` comes before changing the location. – Felix Kling Feb 21 '13 at 11:39
  • @red_alert No it's not. On the same page is the statement I put. – frikkio Feb 21 '13 at 11:51
  • @frikkio You're right, your code is fine. Is better to test it in the 'real' IE8. I have a Virtual Machine with IE8 and WinXP. I've checked and your code is right and fires the alert. – red_alert Feb 21 '13 at 11:59
1

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.

Community
  • 1
  • 1
Xavi López
  • 27,550
  • 11
  • 97
  • 161