How can I show a message to IE6/IE7 browsers to up

2019-01-16 16:50发布

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 I also wanted it to not allow IE7 users to use the main site when logged in (they can view public pages.) The reason is that the main web application has a lot of JavaScript effects that will only work 100% in IE8 rendering mode (or any other browser aside from IE.)

The problem with modifying the ie6 upgrade warning to be ie7 is that it looked like IE8 displayed my webpage in an IE7 rendering mode and "lies" about being ie7 and triggers the IE7 stylesheet code.

So how can I force IE8 to always render my page in IE8 mode?

13条回答
淡お忘
2楼-- · 2019-01-16 17:09

As has been mentioned I'd suggest the best way to achieve this is to use conditional comments to include a stylesheet specific to all versions of IE earlier than 8:

<!--[if lt IE 8]> Include CSS here <![endif]-->

The included CSS could set a warning to be visible or perhaps enable an overlay on the page which 'locks' users out. It might be a good idea to include some rules which hide important elements on the page which could otherwise confuse the user if they do not work as intended.

Your other option is to redirect the user to another page - I'm not a huge fan of redirects but if used with care they can be a suitable solution.

Have you considered why you're locking a large amount of users out of your site? Maybe you should take the time to work out how to either gracefully degrade your JavaScript, or the other way around; 'progressively enhance' with JavaScript.

On the other hand, you might have control over the systems used by the organisation using your site in which case you're probably OK locking people out for using non-standard systems.

查看更多
戒情不戒烟
3楼-- · 2019-01-16 17:09

Using javascript you can ask which browser have sent the request>

<script type="text/javascript">
function detectBrowser()
{
var browser=navigator.appName;
var b_version=navigator.appVersion;
var version=parseFloat(b_version);
if (browser=="Microsoft Internet Explorer")
  && (version>=8))
  {
  alert("Your browser is good enough!");
  }
  else
  {
  alert("It's time to upgrade your browser!");
  }
  }
 </script>
查看更多
手持菜刀,她持情操
4楼-- · 2019-01-16 17:10

Correction to AdamSane's example:

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

查看更多
【Aperson】
5楼-- · 2019-01-16 17:12

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

查看更多
做个烂人
6楼-- · 2019-01-16 17:12

Depends on how you've coded your (X)HTML, but IE8 should use standards mode (not IE7 mode) if you have a strict doctype like:

<!DOCTYPE html 
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

at the top of your HTML files.

XHTML 1.0 Specs - Strictly Conforming Documents

Here's a good post about how different doctypes/etc affect IE8's rendering mode: Understanding Compatibility Modes in Internet Explorer 8

查看更多
爱情/是我丢掉的垃圾
7楼-- · 2019-01-16 17:16

Use this tag:

<meta http-equiv="X-UA-Compatible" content="IE=8" />
查看更多
登录 后发表回答