[英]IE 11 Window.opener.dispatchEvent throws SCRIPT87: Invalid Argument
[英]IE eventDispatch() SCRIPT87: Invalid argument. ERROR
我需要通過自定義事件在2個單獨的窗口后面發送數據。 我使用MDN:CustomEvent()中的 Polifill創建CustomEvent對象。 所以我的代碼看起來:
var chatwindow = window.open(chatRootURL + "chat_window.jsp", "chat", window_options, true);
var event = new CustomEvent("onmessagein", {
detail: data,
bubbles: true,
cancelable: false
});
chatwindow.dispatchEvent(event);
問題是我在IE9中遇到錯誤:
SCRIPT87: Invalid argument.
在最后一行。 在Chrome和Firefox中測試了我的代碼-可以工作。
當我做 :
window.dispatchEvent(event);
事件觸發當前窗口對象。 但我想將其發射到另一個窗口。 我也嘗試在單獨的窗口上觸發正常事件(單擊),並得到相同的錯誤。
有可能嗎? 謝謝。 如果不是,請提出另一個建議
答案是為此使用jQuery。 在網絡中找到的這段代碼效果很好:
href_window.$(href_window.document).trigger(customEvent);
但不是本機JavaScript
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.