javascript - If other than IE show alert - HTMLJS - Stack Overflow

how can I make it so that if the user is not using any version of Internet Explorer to alert them and a

how can I make it so that if the user is not using any version of Internet Explorer to alert them and advise them to use it?

I've tried:

  <html>
   <head>
   <script language="Javascript">
   <![if !IE]>
   alert ("Please use IE")
   <![endif]>
    </script>
    </head>

Thanks

how can I make it so that if the user is not using any version of Internet Explorer to alert them and advise them to use it?

I've tried:

  <html>
   <head>
   <script language="Javascript">
   <![if !IE]>
   alert ("Please use IE")
   <![endif]>
    </script>
    </head>

Thanks

Share Improve this question asked Feb 13, 2013 at 2:02 KoalaKoala 5,5434 gold badges26 silver badges34 bronze badges 3
  • 13 Wait.. you want your users to use IE? – Piccolo Commented Feb 13, 2013 at 2:04
  • 1 Perhaps the OP works for Microsoft... – Lee Taylor Commented Feb 13, 2013 at 2:05
  • 1 stackoverflow./questions/4169160/… – Matt Commented Feb 13, 2013 at 2:05
Add a ment  | 

2 Answers 2

Reset to default 3

You can use:

if (navigator.appName != "Microsoft Internet Explorer")
{
    alert("Please use IE");
}

OR:

if (navigator.userAgent.indexOf("MSIE") == -1)
{
    alert("Please use IE");
}

FYI, you could also use the examples below but Conditional Comments are REMOVED from Internet Explorer 10.

Otherwise you could use:

<!--[if !IE]><!-->
<script type="text/javascript">
   alert("Please use IE");
</script>
<!--<![endif]-->

OR this:

<!--[if IE]><script type="text/javascript">window['isIE'] = true;</script><![endif]-->
<script type="text/javascript">
   if (!window.isIE) alert("Please use IE");
</script>

But still; to get this functionality in IE10; there is a workaround, which is opting into IE 9 behaviour via this meta tag:

<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE9">

If you're using jQuery you can do:

if (!$.browser.msie) {
    alert( "Please Use IE" );
}

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745136384a4613220.html

相关推荐

  • javascript - If other than IE show alert - HTMLJS - Stack Overflow

    how can I make it so that if the user is not using any version of Internet Explorer to alert them and a

    3小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信