那麼,我正在開發一個firefox插件,它會自動重新加載一組給定的URL並進行一些修改。它不可能顯示整個代碼。所以,我只是複製粘貼部分代碼給我的錯誤。DOMContentLoaded事件停止觸發。爲什麼?
DOMContentLoaded
事件被認爲是觸發頁面加載的所有內容,並且它正確執行。問題是,如果我打開一個新選項卡,則在舊選項卡中不會觸發DOMContentLoaded
事件。
//Any code here runs only for the first time u start the browser
window.addEventListener("load", function() { myExtension.init(); }, false);
var myExtension = {
init: function()
{
var appcontent = document.getElementById("appcontent");
if(appcontent)
appcontent.addEventListener("DOMContentLoaded", myExtension.onPageLoad, true);
},
onPageLoad: function(aEvent)
{
var doc = aEvent.originalTarget; // doc is document triggered "onload" event
//execute on one the top page (not on iframes)
if ((aEvent.originalTarget.nodeName == '#document') && (aEvent.originalTarget.defaultView.location.href == gBrowser.currentURI.spec))
{setTimeout(function(){showInError(doc.location='about:home'}, 500);}
},
}
我想編寫一個簡單的方法)我使用Firefox的問題(對不起我的英語不好)
1,標籤(比如標籤一號)連續重載時我想要。
2)選項卡第1頁繼續,如果我離開的頁面不間斷地反覆加載(這是它想要的東西)
3)如果我打開一個新的標籤(標籤說2號),新標籤(標籤號2)開始按照我的意願不斷重新加載。但是,選項卡號。 1停止重新加載。
我想要的是繼續重新加載兩個製表符號1和製表符號。 2.如何做到這一點?我的代碼有什麼問題?