How can I catch the event when "a page starts to load in the Browser"?
How can I access the HTML and manipulate it with XUL?
How can I catch the event when "a page starts to load in the Browser"?
How can I access the HTML and manipulate it with XUL?
There is a large amount of documentation and sample code for this very task already on Mozilla's site. You question is a big vague though, so I may be linking you to the wrong page.
No, i think his question is similar to mine. Curently, all documentation on MDC tells us how to access our "chrome" window's document but what we want is this:
HOW?
This is essentially taken from the mozilla site
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(event) {
var doc = event.originalTarget;
var myDiv = doc.getElementById("myDiv");
//do something interesting with it
}
}
have fun
I had the same question as this. I found documentation, but had trouble getting the code to run in Firefox 3.6.12. I made some changes and managed to get it working:
this._loadHandler = function(event) {
var myDomain = 'www.yahoo.com';
let doc = event.originalTarget;
//alert(doc.defaultView.location.href);
if (doc instanceof HTMLDocument) {
var re = new RegExp(myDomain);
if (doc.defaultView.location.href.match(re)) {
alert("Successful match");
}
}};
gBrowser.addEventListener("load", this._loadHandler, true);
This was modified from the example here: https://developer.mozilla.org/en/XUL_School/Intercepting_Page_Loads
HTH