I am developing a Firefox extension that places a button on the status bar. When the button is clicked, the extension adds some Javascript to the current page. This Javascript has a function that I would like to use with some parameters. I was able to enter the code, I checked the page through Firebug and verified that JS was entered. How can I call a Javascript function on a page from my extension?
- Additional Information
Here is the code I use to enter my Javascript:
var doc = window.content.document;
var visibilityJS = doc.createElement("script");
visibilityJS.setAttribute("type", "text/javascript");
visibilityJS.setAttribute("charset", "UTF-8");
visibilityJS.setAttribute("src", "chrome://visibility/content/scripts/visibility.js");
head.appendChild(visibilityJS);
alert("Executing testfunction");
window.content.document.defaultView.testFunction();
.. and the code inside my JS file, which I will enter. i.e. visibility.js
window.testFunction = function() {
alert("Message");
}
Thank.
source
share