2017-10-20 76 views
0

我有這個JavaScript代碼,當瀏覽器檢測到用戶關閉彈出式窗口時運行。它適用於瀏覽器firefox,opera,chrome,但是我在IE瀏覽器中遇到了一個錯誤(錯誤在荷蘭語中,所以我試圖翻譯)。它確實打開了一個彈出窗口,但它也會在Internet Explorer中打開一個新選項卡,而其他瀏覽器則不會這樣。JavaScript的Internet Explorer不會檢測window.closed

這是JS代碼。該錯誤是給上線

無法關閉未定義引用的屬性或檢索 引用爲空值

function hyperLink(link) {  
     var newWindow = window.open(link.href, "Hyperlink", "status=yes,toolbar=yes,scrollbars=yes,resizable=yes,width=" + screen.width/1.5 + ",height=" + screen.height/1.5 + ""); 

     var interval = window.setInterval(function() {    
      if (newWindow.closed !== false) // for opera 
      {     
       $.ajax({ 
        url: "index.php?route=extension/module/filter_product/getSupplierName", 
        type: "POST", 
        data: {supplier_name : link.name}, 
        success: function(result) { 
         // your success handler 
         /*console.log("success"); 
         console.log(result);*/ 
        } 
       }); 

       window.clearInterval(interval); 
      } 
     }, 500);  
} 

HTML代碼:

<div class="col-md-3 text-center hyperlink-image"> 
    <a href="<?php echo $supplier['href']; ?>" onclick="hyperLink(this)" target="Hyperlink" name="<?php echo $supplier['name']; ?>"> 
     <img src="<?php echo $supplier['thumb']; ?>" alt="<?php echo $supplier['name']; ?>"/> 
    </a> 
</div> 

回答