Firefox page load detection

How to determine when a page is loaded (on any tab) with the firefox extension (automatically, without a start button or anything else) (and, for example, display a warning message)?

+3
source share
2 answers

https://developer.mozilla.org/en/Code_snippets/On_page_load

Do not miss this part: "

The current trunk chests in Firefox will run the onPageLoad function for not only documents, but xul: images (favicons in tabbrowser). If you only want to process documents, provide aEvent.originalTarget.nodeName == "#document" 1 .

"

+3
source
function startup() {

mainWindow = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
                         .getInterface(Components.interfaces.nsIWebNavigation)
                         .QueryInterface(Components.interfaces.nsIDocShellTreeItem)
                         .rootTreeItem
                         .QueryInterface(Components.interfaces.nsIInterfaceRequestor)
                         .getInterface(Components.interfaces.nsIDOMWindow); 

    mainWindow.getBrowser().addEventListener("load", listener, false);


    // Sidebar is loaded and mainwindow is ready                   
    }

    var listener = function(e){
        alert("Hai");
        //To remove event listener
        //mainWindow.getBrowser().removeEventListener("load",listener, false);
    }  


window.addEventListener("load", startup, false);

.

, , .

+2

Source: https://habr.com/ru/post/1713648/


All Articles