locked
IE8 reports as IE7 using conditional comments in an IFRAME RRS feed

  • Question

  • I've done numerous tests and as far as I can tell - IE reports as 7 when the condition is tested from within a page loaded in an IFRAME.

    The following code works correctly outside of an IFRAME

    <html>
    <!--[if lte IE 7]>
    <p>Internet Explorer 7 or older</p>
    <![endif]-->
    <!--[if gte IE 8]>
    <p>Internet Explorer 8 or later</p>
    <![endif]-->
    </html>

    But if it's loaded from an IFRAME in another page - it incorrectly shows that it's IE 7

    Does anyone have any suggestions for an alternate approach/work around?

    I guess I could use JavaScript - but that seems like overkill - especially as I'm ultimately just trying to detect versions of Internet Explorer older than 8.
    Monday, December 14, 2009 8:58 PM

Answers

  • I ended up using JavaScript - but even then had to jump through hoops because compatiblity mode still reports IE8 as IE7. The trick is to look for 'trident' in the user agent string - as per this blog http://blogs.msdn.com/giorgio/archive/2009/04/14/how-to-detect-ie8-using-javascript-client-side.aspx

    Here's a snippet if it helps anyone...

    <!--[if IE]>
      <SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
      if (navigator.userAgent.toUpperCase().indexOf("TRIDENT/") == -1)
         //Do something here
    </SCRIPT>
    <NOSCRIPT>
      //Do something good if we can't use JavaScript
    </NOSCRIPT>
    <![endif]-->

    I still used the outer conditional test because I didn't want this code to even evaluate under other browsers.
    Friday, December 18, 2009 1:41 AM