Send message to extension from a web page

Hello,

I am porting an extension from Chrome to Firefox and I need a way to send a message to extension from a web page. My Chrome extension registers a listener using chrome.runtime.onMessageExternal which receives messages sent from web page using chrome.runtime.sendMessage.

But according to documentation this is not supported in Firefox. Is there some other way to talk to an extension from web page?

1 Like

Both website and extension can listen to and emit (either via postMessage or CustomEvent) events. You can use those to communicate in chrome and Firefox:

In Firefox (but not in chrome) you can expose privileged functions from the extension to the web page:

1 Like