Is there a way to call a function in the background script from the popup? I can't explain it much further than that question. It's not an error I'm having with what I'm trying to do but rather something I completely don't know how to do. I want to make it possible to click a button in the popup page that'll call a function defined in the background page.
相关问题
- Keeping track of variable instances
- How to get the maximum of more than 2 numbers in V
- F#: Storing and mapping a list of functions
- WPF ComboBox with custom dropdown width
- VBA Self-Function returns #VALUE! Error on cell, w
相关文章
- Accessing an array element when returning from a f
- Equivalent to window.setTimeout() for C++
- How can I write-protect the Matlab language?
- Java Equivalent to iif function
- Progressive web app(PWA) vs Electron vs Browser ex
- Start an Activity from another Activity on Xamarin
- How do you create a formula that has diminishing r
- Add multiplication signs (*) between coefficients
It is indeed possible, using Message Passing.
popup.js
background.js
Try this
You can still use
chrome.extension.sendMessage
. But that is getting deprecated. Usechrome.runtime.sendMessage
andchrome.runtime.onMessage.addListener
instead.You can just call background.js functions in popup.js. You don't need to do anything extra. At least that is the case for me.
Edit: you probably need to add
"background": { "scripts": "background.js" }
in your manifest.json file.