【问题标题】:Does @_jscript no longer represent true in IE11? [duplicate]@_jscript 在 IE11 中不再代表 true 吗? [复制]
【发布时间】:2015-01-30 07:00:33
【问题描述】:
<script>
/*@cc_on
   @if (@_jscript)
      alert("IE.");
   @else*/
      alert("Not IE.");
   /*@end
@*/
</script> 

当我运行上面的代码时,Firefox 和 IE 都显示了一个弹出对话框,告诉我“不是 IE。”。 为什么会这样。 @_jscript 是否不再在 IE 11 中定义?

IE版本:11.0.9600.17501

【问题讨论】:

  • 是的 IE 开始支持 W3C 标准,包括放弃对非标准浏览器嗅探的支持。
  • 对不起。我的英文不是很好。所以我不知道“条件编译”这个词,也没有去搜索那个问题。

标签: javascript jscript


【解决方案1】:

@_jscript 是否不再在 IE 11 中定义?

没有。

IE10+ 不支持早期版本 IE 中的一些功能。已删除。

不用@_jscript你可以试试下面的代码

 function msieversion()
{
  var ua = window.navigator.userAgent
  var msie = ua.indexOf ( "MSIE " )

  if ( msie > 0 )      // If Internet Explorer, return version number
     return parseInt (ua.substring (msie+5, ua.indexOf (".", msie )))
  else                 // If another browser, return 0
     return 0

}

Reference

【讨论】:

  • 请参阅stackoverflow.com/help/referencing 以获取有关引用非您编写的内容的帮助。由于您的答案目前正在编写,听起来您好像是代表 IE 团队发言。
  • 非常感谢。我认为 IE 让网络编程变得有点困难......
  • 还有,这和HTML5解析无关。
  • @BoltClock 感谢您的纠正......我更新了我的答案
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-08-04
  • 2018-05-17
  • 1970-01-01
  • 1970-01-01
  • 2021-04-15
  • 1970-01-01
相关资源
最近更新 更多