-
Notifications
You must be signed in to change notification settings - Fork 347
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to access background script public function #64
Comments
Try Also you can use messages to/from background page: popup.js
background.js
|
This happens because the background page in this setup is a module, so you can't access the methods from this module with this direct approach because the module encapsulates everything instead of defining everything in the global scope (which allowed you do this access). Access directly to the methods from other contexts is a slightly bad practice, so the suggested method by @SzpakLabs is the recommended way to do this. |
This is also somewhat bad practice, but if you really need to make your function global to the window object and access it with |
In my popup.js i used to do:
bg = chrome.extension.getBackgroundPage()
to get access to the background page. Then I could dobg.xxx()
...However, with this setup, i am getting:
Any clue?
The text was updated successfully, but these errors were encountered: