How to detect IE6, and show alert?

不想你离开。 提交于 2019-12-10 12:55:29

问题


I'm trying to show an alert when a user using IE6 uses my site. I'm thinking something like this will work:

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

I'd test this but I don't have a Windows box I can use ATM. Is this the correct way to do it?


回答1:


Yes, that works:

Of course, you could use something like this, which is a bit more friendly.




回答2:


This has already been answered but I really wanted to post something I did for this. My personal website, have configured a similar script:

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

So whenever anyone with IE vesion less then 9, the browser redirects to this page.




回答3:


This way to detect Internet Explorer version

<!--[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]-->

More detail you can refer link as here http://msdn.microsoft.com/en-us/library/ms537512.aspx

  • Thanks Abhi.



回答4:


Yes the code you posted should totally work. Maybe just add a semicolon at the end of the line.

And one more interesting way:

http://www.ie6nomore.com/




回答5:


Perhaps this may be of some use to you.




回答6:


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


来源:https://stackoverflow.com/questions/4743530/how-to-detect-ie6-and-show-alert

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!