简体   繁体   English

防止在 IE v11 上执行第二个块

[英]Prevent execute second block on IE v11

I have a conditional when I execute this On IE v11 event the first block is true is not execute because I have error on my second one, My question is how I can void this behavior I Mean in this case I want to show the alert and don't execute nothing more if I am IE v11.当我在 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);
}

Well, its a dirty solution and I highly do not recommend to use it.嗯,这是一个肮脏的解决方案,我强烈不建议使用它。 But you can use eval like that:但是你可以像这样使用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);
}

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

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