【问题标题】:Prevent execute second block on IE v11防止在 IE v11 上执行第二个块
【发布时间】:2019-07-26 17:12:48
【问题描述】:

我在执行此操作时有一个条件 在 IE v11 事件上,第一个块为真不执行,因为我的第二个块有错误,我的问题是如何使这种行为无效 我的意思是在这种情况下我想显示如果我是 IE v11,则不再执行警报。

if (window.navigator.userAgent.indexOf('Trident/') > 0) {
        alert('this browser is not supported');
         return
    } else {
        var se = `some here`; // <- this is not supported on EI v11
        console.log('here',se);
}

【问题讨论】:

标签: javascript internet-explorer


【解决方案1】:

嗯,这是一个肮脏的解决方案,我强烈不建议使用它。但是你可以像这样使用eval

if (window.navigator.userAgent.indexOf('Trident/') > 0) {
  alert('this browser is not supported');
  return;
} else {
  eval('var se = `some here`'); // <- this is not supported on EI v11
  console.log('here',se);
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-09-26
    • 1970-01-01
    • 2010-11-12
    • 2014-07-09
    • 2015-03-12
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多