开发者

Detect IE7 and below

What is the best way programatically on a webpage (using jquery/javascript/html/asp.net/css anything realy) to display a message for users of IE 7 and below?

I've made the开发者_JAVA技巧 decision for the site not to support those browsers (the target audience of the site is quite technically up-to-date), so would like to display a notification bar at the top of the page telling them the pages might not display properly.


I would use Conditional comments


Have a look at the IE 6 Blocker Script.


Conditionnal comments are the way to go.

<!--[if lte IE 7]>
<div class="info">Message saying you're sorry.</div>
<![endif]-->


Using JavaScript you can use the Navigator property to check the browser version

if((navigator.appName != 'ie') && (navigator.appVersion <= 7))
{
    alert('Incompatible Browser')
}

I haven't actually tested this code but I think it should work. There's some more info on W3Schools website


I've been using this terrific script. It adds CSS classes to your tag. Then, you only need one CSS file, and you can pinpoint browsers, versions & operating systems.


If there are specific features you want to use which are broken or unsupported in old IEs, you could use a library like Modernizr to detect support for those specific features, and show your message if the browser doesn't support the features you need.

The advantage of this is that it would also pick up users of really old versions of other browsers (yes, there are a few of them still around). Even some relatively recent mobile phone browsers may give you issues.

Another advantage of this method is that it will also be easier to adapt the script to include other required features when you enhance the site again in the future.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜