3
我試圖在Firefox的擴展中禁用beforeUnload對話框,這個擴展中的工作一直持續到FF28,通過將窗口封裝在XPCNativeWrapper中並使用addeventlistener重新定義window.onbeforeunload。在Firefox 29擴展中禁用beforeunload對話框
例的JavaScript:
var win = new XPCNativeWrapper(window, "onbeforeunload", "event", "addEventListener()");
var beforeUnload = win.onbeforeunload;
win.onbeforeunload = null;
var newBeforeUnload = function(e) {
beforeUnload();
//code to remove dialog
}
win.addEventListener('beforeunload', newBeforeUnload, false);
這已停止在FF29工作時,beforeUnload方法改變頁面的位置。在FF29中,我收到一個錯誤「從腳本被拒絕訪問'chrome://browser/content/page.html'」。 JS的頁面上
例子:
window.onbeforeunload = function() {
parent.frame2.location="page.html";
};
你想編輯插件源代碼? – Noitidart