Iwa*_*man 16 internet-explorer cross-browser popup
我想使用我的网站警告Internet Explorer 6的用户,IE6过去曾与我的网站存在严重的兼容性问题.做这个的最好方式是什么?
理想情况下,我希望显示一条消息(不是新窗口,但如果可能的话,还会显示一个消息框),它会警告IE6用户这些问题,并建议他们更新到IE7,Firefox 3或Opera 9.5.
dif*_*ent 34
目标IE的最佳方法是使用条件注释.然后,您可以添加一些仅在Internet Explorer中显示的特定HTML.
<!--[if IE 6]>
<h1>Please upgrade your browser!</h1>
<![endif]-->
Run Code Online (Sandbox Code Playgroud)
更多关于这个问题:
http://www.quirksmode.org/css/condcom.html
小智 13
好的,我会让这很容易.没有弹出窗口!统计灾难.这是一个很好的小东西坐在上面.我只是真的担心IE 6或更早,因为它是最糟糕的罪魁祸首.以下是条件声明(在我看来最好的方式).
坚持这个(放入你想要的任何内容):
<!--[if lte IE 6]>
<div id="warning">
<h4 class="red">Your Browser Is Not Supported!</h4><br />
<p>Please upgrade to <a href='http://getfirefox.com'>FireFox</a>, <a href='http://www.opera.com/download/'>Opera</a>, <a href='http://www.apple.com/safari/'>Safari</a> or <a href='http://www.microsoft.com/windows/downloads/ie/getitnow.mspx'>Internet Explorer 7 or 8</a>. Thank You! <a href="#" onClick="document.getElementById('warning').style.display = 'none';"><b>Close Window</b></a></p>
</div>
<![endif]-->
Run Code Online (Sandbox Code Playgroud)
将它贴在外部造型板上.我不会使用内联样式.
#warning {position:relative; top:0px; width:100%; height:40px; background-color:#fff; margin-top:0px; padding:4px; border-bottom:solid 4px #000066}
Run Code Online (Sandbox Code Playgroud)
无论你想要它的风格 - 坚果!你可以使用javascript来检测任何浏览器,所以如果你知道如何,它可以增加更多的特异性.
这将是一个非常小的框,位于您的内容之上,让您的用户看到他们的浏览器很糟糕.
如果你想确定它是否支持浏览器,你可能想要使用jQuery的浏览器检测,例如:
<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>
Run Code Online (Sandbox Code Playgroud)
更新:正如不同所说,更好的选择是使用IE if语句,例如:
<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]-->
Run Code Online (Sandbox Code Playgroud)
此选项更好,因为它不需要浏览器版本"完美".但是,如果您要检测其他浏览器,因为它们不支持if语句,这将无效.然后你可能想用jQuery来检测浏览器,虽然我建议尽量避免使用它.
条件注释提供了仅显示特定版本的Internet Explorer的内容的方法.
<!--[if IE 6]>
Special instructions for IE 6 here
<![endif]-->
Run Code Online (Sandbox Code Playgroud)
有一个名为Push Up the Web的项目,建议所有用户升级到他们浏览器的新版本.它不引人注目且易于添加.
正如一些人所建议的那样,最好的办法是使用条件注释有效地定位Internet Explorer.
对于其他评论者,随着Internet Explorer 8的发布(有效添加了两个额外的浏览器进行测试:标准+兼容模式),Internet Explorer 6已经开始运行.现在是时候让这些人升级浏览器,在某些情况下升级操作系统/计算机.Internet Explorer 6 阻碍了Web的发展.支持资源是一种耗费.它已达到Netscape 4的地位.主要的网站和公司也加入了这场战斗.
更多阅读:
归档时间: |
|
查看次数: |
60799 次 |
最近记录: |