I want to write a simple firefox extension.
How can I get a reference to the loaded document object in a browser window? For example, how can I access the document in this html page loaded here on stackoverflow? According to the vague mozilla development center I can use browser.contentDocument, but it is not working for me.
<?xml version="1.0"?>
<overlay id="sample"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/x-javascript">
function change(){
//var doc = document.getElementsByTagName("browser")[0].contentDocument;
//var doc = document.browser.contentDocument;
var doc = browser.contentDocument;
var body = doc.getElementsByTagName("body")[0];
var text = doc.createTextNode("blah");
body.appendChild(text);
}
</script>
<statusbar id="status-bar">
<statusbarpanel id="my-panel" label="click me" onclick="change();" />
</statusbar>
</overlay>