簡體   English   中英

jQuery在Internet Explorer 11中不起作用

[英]jQuery doesn't work in Internet Explorer 11

我的ajax success:function()運行一行代碼,這將打開一個新窗口並將數據插入其中。 現在,我的代碼看起來像這樣:

 success: function(data) { var url = location.href; var w = window.open(url); w.onload = function() { w.$('#main').html(data); }; } 
 <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> 

它在Chrome中工作正常,但是如果我想在Internet Explorer 11中運行它,將不會執行w.$('#main').html(data) 我也嘗試過:

 success: function(data) { var url = location.href; var w = window.open(url); w.addEventListener('load', function() { w.$('#main').html(data); }, { once: true }); } 

在Chrome中也可以正常工作,但使用IE可以得到與上述代碼相同的結果。 有人知道為什么此代碼在IE中不起作用嗎?

我在以下線程中找到了解決方案: Internet Explorer中的addEventListener

我需要使用attachEvent方法而不是addEventListeneronload

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM