不支持浏览器时显示消息 [英] Display a Message When a Browser is Unsupported

查看:202
本文介绍了不支持浏览器时显示消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想警告使用我的网站的Internet Explorer 6的用户,IE6在过去与我的网站有严重的兼容性问题。这是最好的方法是什么?

I want to warn users of Internet Explorer 6 using my site, that IE6 has had serious compatibility issues with my site in the past. What is the best way to do this?

理想情况下,我想有一条消息出现(不是一个新的窗口,但消息框,如果可能),警告IE6用户的问题和建议,他们更新到IE7,Firefox 3或Opera 9.5。

Ideally, I want to have a message appear (not a new window, but a message box, if possible) that warns IE6 users of the issues and reccommends they update to either IE7, Firefox 3 or Opera 9.5.

推荐答案

如果你想确定它是否除了支持浏览器,你可能想使用jQuery的浏览器检测,例如:

If you want to determine if it's anything other than support browsers, you might want to use jQuery's browser detection, something like:

<script type="text/javascript">
// check if browser is IE6 (when IE) or not FF6 (when FF)
if (($.browser.msie && $.browser.version.substr(0,1) == '6')
    || ($.browser.mozilla && $.browser.version.substr(0,1) != '3')) {
        $('#browserWarning').show();
}
</script>

更新不同说,一个更好的选择是使用IE if语句,如: / p>

Update: As different said, a much better option is to use the IE if statements, such as:

<style type="text/css">
/* this would probably be in a CSS file */
#browserWarning { display:none; }
</style>
<!--[if IE 6]>
<style type="text/css">
#browserWarning { display:; }
</style>
<![endif]-->

此选项更好,因为它不需要浏览器版本完美。这将不工作,虽然,如果你想检测其他浏览器,因为他们不支持if语句。然后你可能想使用jQuery来检测浏览器,虽然我建议尽量避免它。

This option is much better because it doesn't require the browser version to "perfect". This won't work though, if you want to detect other browsers as they don't support the if statements. Then you may want to use jQuery to detect the browser, although I would recommend trying to avoid it as much as much as possible.

这篇关于不支持浏览器时显示消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆