Forum Moderators: open
what it does is add an event listener to "DOMContentLoaded" - so when a page is loaded in the browser, it executes the "onPageLoad()" function.
in my toolbar XUL, I have this element:
<textbox id="xultextbox" value="blank on purpose" readonly="true"/>
so, the following code should write a variable into the textbox
onPageLoad: function(aEvent) {
var doc = aEvent.originalTarget; // doc is document that triggered "onload" event
// do something with the loaded page.
if(doc.location.href.search("myapp.com/mypage.php") > -1){
alert(myvariable); // this works
document.getElementById('xultextbox').value = myvariable // this doesn't work
}
}
the problem here is scope. "onPageLoad" is an event happening in the _content - that is, the web page. so when I reference "document.getElementById()" within the event, it's looking for my XUL textbox on the page, which ain't gonna be successful.
I need to know: how do I send that variable from the page into my toolbar?