How can I show a message to IE6/IE7 browsers to upgrade to IE8 and have IE8 not show the IE7 warning?

前端 未结 13 932
醉话见心
醉话见心 2020-12-08 02:53

I want to only allow users with IE8 (not IE6, IE7) or another browser to access my site when logged in.

I followed: http://code.google.com/p/ie6-upgrade-warning/ But

相关标签:
13条回答
  • 2020-12-08 03:31

    Rather than try to force IE 8+ mode, I use a combination of conditional comments and a simple javascript check. The document.documentMode property was added to IE in version 8, so if it exists at all (regardless of value, though it HAS to be 7 with this code) it means we're in compatibility mode and should not show the warning:

    <!--[if lte IE 7]>
        <script>
            if (!document.documentMode) { //if documentMode exists, this is a later IE in compatibility mode
                showBadBrowserMessage();
            }
        </script>
    <![endif]-->
    
    0 讨论(0)
  • 2020-12-08 03:32

    You can use CSS Conditional Comments

    <!--[if IE 8]>
    Special instructions for IE 6 here
    <![endif]-->
    
    0 讨论(0)
  • 2020-12-08 03:34

    here is a good link that suggest some solution

    http://garmahis.com/tools/ie6-update-warning/

    personally i like fourth solution(http://www.browser-update.org/)

    just a piece of cake

    0 讨论(0)
  • 2020-12-08 03:38

    Correction to AdamSane's example:

    <!--[if lt IE 8]> Special instructions for IE 7 or less here <![endif]-->

    0 讨论(0)
  • 2020-12-08 03:39

    Use this tag:

    <meta http-equiv="X-UA-Compatible" content="IE=8" />
    
    0 讨论(0)
  • 2020-12-08 03:44

    Here is this cool script that works for all old browsers:

    <script type="text/javascript"> 
        var $buoop = {vs:{i:7,f:5,o:12,s:5,n:9}}; 
        $buoop.ol = window.onload; 
        window.onload=function(){ 
         try {if ($buoop.ol) $buoop.ol();}catch (e) {} 
         var e = document.createElement("script"); 
         e.setAttribute("type", "text/javascript"); 
         e.setAttribute("src", "//browser-update.org/update.js"); 
         document.body.appendChild(e); 
        } 
    </script> 
    

    Note: If the visitor ignores the advice, it won't appear again for some time.

    More can be found: here

    0 讨论(0)
提交回复
热议问题