问题描述
如何调用在我的扩展中声明的Javascript函数,使用我的网页上的HTML按钮?
我有一个html页面,里面有一个按钮。当用户点击按钮,它会调用一个函数,我已经在我自己的firefox扩展中声明。
网页,最简单和最安全的方法来做你想做的事情就是在网页中发送一个自定义的DOM事件,并在扩展代码中监听它:
(未更新到最新的Firefox版本,但它很干净,应该很容易更新)。
How to call a Javascript function declared in my extension, using a html button from my web page?
I have a html page, with a button inside. When the user click the button, it will call a function that I already declared inside my own firefox extension.
Since you control the web page, the easiest and the safest method to do what you want would be to dispatch a custom DOM event in the web page and listen to it in the extension code:
Here's an example extension I wrote that does exactly this http://mozilla.doslash.org/cw/ (not updated to the most recent Firefox version, but it's clean and should be easy to update).
这篇关于如何从HTML按钮调用Firefox扩展的功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!