繁体   English   中英

如何检测IE6,并显示警报?

[英]How to detect IE6, and show alert?

我正在尝试在使用IE6的用户使用我的网站时显示警报。 我在想这样的事情会起作用:

<!--[if IE 6]>
<script language="Javascript">
alert ("The year 2004 just called - they want their browser back!")
</script>
<![endif]-->

我测试了这个,但是我没有可以使用ATM的Windows盒子。 这是正确的方法吗?

是的,这有效:

替代文字

当然,你可以使用这样的东西 ,它更友好一些。

这已经得到了解答,但我真的想发布一些我为此做的事情。 我的个人网站,配置了类似的脚本:

  <!--[if lt IE 9]>
  <script type="text/javascript">
    location.replace("/ie/?next=/");
  </script>
  <![endif]-->

因此,每当IE vesion少于9的任何人,浏览器都会重定向到此页面

这种方式可以检测Internet Explorer版本

<!--[if IE 6]>
<p>Welcome to any incremental version of Internet Explorer 6!</p>
<![endif]-->


OR 

<!--[if gte IE 6]>
<SCRIPT LANGUAGE="Javascript">
alert("Congratulations! You are running Internet Explorer 6 or greater.");
</SCRIPT>
<P>Thank you for closing the message box.</P>
<![endif]-->

更多详细信息,请参阅此处链接http://msdn.microsoft.com/en-us/library/ms537512.aspx

  • 谢谢阿比。

是的,您发布的代码应该完全有效。 也许只需在行尾添加分号即可。

还有一个有趣的方式:

http://www.ie6nomore.com/

也许可能会对你有所帮助。

#lowCssSupportNotice {
    display: none !important;
    display: block; /* IE6 sees this */
    position: absolute;
    left: 50%;
    top: 50%;
    width: 300px;
    height: 300px;
    margin: -150px 0 0 -150px;
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM