How do I execute a page-defined JavaScript function from a Firefox extension?

前端 未结 5 1916
感动是毒
感动是毒 2021-01-04 21:14

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 insid

5条回答
  •  甜味超标
    2021-01-04 21:50

    It is for security reasons that you have limited access to the content page from extension. See XPCNativeWrapper and Safely accessing content DOM from chrome,

    If you control the page, the best way to do this is set up an event listener in the page and dispatch an event from your extension (addEventListener in the page, dispatchEvent in the extension).

    Otherwise, see http://groups.google.com/group/mozilla.dev.extensions/msg/bdf1de5fb305d365

提交回复
热议问题