How do I execute a page-defined JavaScript function from a Firefox extension?
Posted
by yuku
on Stack Overflow
See other posts from Stack Overflow
or by yuku
Published on 2008-09-30T02:32:19Z
Indexed on
2010/03/26
18:43 UTC
Read the original article
Hit count: 265
Hi, I'm creating a Firefox extension for demo purposes. I to call a specific JavaScript function in the document from the extension. I wrote this in my HTML document (not inside extension, but a page that is loaded by Firefox):
document.funcToBeCalled = function() {
// function body
};
Then, the extension will run this on some event:
var document = Application.activeWindow.activeTab.document;
document.funcToBeCalled();
However it raises an error saying that funcToBeCalled
is not defined.
Note: I could get an element on the document by calling document.getElementById(id);
© Stack Overflow or respective owner