如果浏览器不是Internet Explorer 9或更高版本,则显示消息 [英] Show a message if the browser is not internet explorer 9 or greater

查看:1759
本文介绍了如果浏览器不是Internet Explorer 9或更高版本,则显示消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想向我的用户显示一个如下所示的栏:

I would like to show my users a bar that looks like this, if:


  1. 浏览器不是IE;或

  2. 浏览器是IE但是版本8或更早版本

(请注意,屏幕截图仅供参考,我的网站支持IE 9

(Note that the screenshot is just for illustration - IE 9 is supported for my site.)

我发现这个漂亮的jQuery插件,但我不想使用弹出窗口。

I found this nice jQuery plugin, but I don't want to use popups.

http://jreject.turnwheel.com/

我将要实现的网站是一个Sharepoint 2013网站,所以我将使用内容编辑器webpart来包含您提供的HTML内容,并且栏应该在其他所有内容的顶部。

The site where I will implement this is a Sharepoint 2013 site, so I will use a content editor webpart to include the HTML content you provide and the bar should be at the top of everything else.

如果需要,请包括CSS查看屏幕截图?

Please include CSS if needed to make it look as the screenshot?

推荐答案

HTML



IE 9及更早版本(直到,我想,IE 4)可以使用HTML中的条件注释来标识。

注意到时,您可以使用它们在IE 8及更早版本中警告IE用户,如下:

As @Jost noted, you could use them to warn IE users on IE 8 and earlier, like this:

<!--[if lte IE 8]>
    BANNER HERE
<![endif]-->

但是,由于IE 10丢弃了对这些的支持,您不能使用它们来标识非IE浏览器。

However, as IE 10 dropped support for these, you can't use them to identify non-IE browsers.

jQuery用于包含浏览​​器检测模块( $。browser ),但它在jQuery 1.9 中删除。如果您可以使用早期版本的jQuery(例如 1.8.3 )或 jQuery Migrate插件,那么您可以使用此来显示横幅。

jQuery used to include a browser detection module ($.browser), but it was removed in jQuery 1.9. If you can use an earlier version of jQuery (e.g. 1.8.3) or the jQuery Migrate plugin, then you could use this to show the banner.

if ( !$.browser.msie || $.browser.version < 9 ) {
    // Add banner to the page here.
}



一般浏览器检测



请注意,浏览器检测很困难。新的浏览器一直在出来,所以任何浏览器支持插件可能会迅速过时,因为您的警告消息的基础。 jQuery的浏览器检测是最一致的维护,甚至他们最后放弃了。

Browser Detection in general

Please note that browser detection is difficult. New browsers are coming out all the time, so any browser support plugin can rapidly become out of date, as can the premise on which you base your warning messages. jQuery's browser detect was the most consistently maintained, and even they gave up on it in the end.

这些天,web开发人员通常需要编写代码,浏览器,并使用功能检测来处理不支持他们想要使用的功能的浏览器。

These days, web developers are generally expected to write code that works cross-browser, and use feature-detection to deal with browsers that don't support the features they want to use.

当您在SharePoint网站上工作时,用于公司内部使用,而公司是以微软为中心的。这听起来像是你开发的网站工作在IE,并忽略其他浏览器在开发过程中。

As you're working on a SharePoint site, presumably it's for internal company use, and the company is Microsoft-centric. It sounds like you're developing the site to work in IE, and ignoring other browsers during development.

如果你可以合理地期望大多数用户是在某些版本的IE,也许条件注释警告就够了。

If you can reasonably expect most of your users to be on some version of IE, maybe the conditional comment warning is enough.

这篇关于如果浏览器不是Internet Explorer 9或更高版本,则显示消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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