I'm writing a Firefox extension,
This is my XUL (no problem there)
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE overlay SYSTEM "chrome://locale/myDtd.dtd">
<page id="overlay" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:xhtml="http://www.w3.org/1999/xhtml">
<script type="application/x-javascript" src="chrome://addon/content/test.js" />
</page>
And here is the problematic part of the Javascript test.js
window.addEventListener("load",
function(event) {
var appcontent = window.document.getElementById("appcontent");
appcontent.addEventListener("load",onEventLoad,true);
}, true);
The second 'load' listener on appcontent is too slow for my needs. The 'load' event is triggered when the DOM is done loading.
My question: Does anyone have an idea of how to run code as soon as a document starts loading (before the load event of the DOM) ? (wish a onBeforeLoad or onRequestStart event existed)
In Chrome extensions, we can use "run_at": "document_start" in 'manifest.json', and in Safari extensions, we can use 'Starting script' in extension builder but in Firefox ... I don't know how to do the same trick.
I need this to start looking at elements in the DOM as soon as they arrive (but that's another story).
I appreciate any help.