簡體   English   中英

防止在 IE v11 上執行第二個塊

[英]Prevent execute second block on 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);
}

嗯,這是一個骯臟的解決方案,我強烈不建議使用它。 但是你可以像這樣使用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