How To Load Js From A Chrome Extension Popup
background I simply want to create a chrome extension where I click on the extension icon, it loads a popup that loads a javascript file. I was able to do an html only popup simpl
Solution 1:
Many ways:
Add a script for example
popup.js
inpopup.html
and callchrome.runtime.getBackgroundPage(function callback)
to interact with event page.popup.html
... <scriptsrc="popup.js"></script> ...
popup.js
chrome.runtime.getBackgroundPage(backgroundPage => backgroundPage.testMethod());
eventsPage.js
consttestMethod = () => console.log('test');
Use Message Passing(there are many examples in this link) to communicate with event page.
Since you want to transfer data between popup page and event page, there are many other workarounds, for example, we could use global storage such as
chrome.storage
to save/load/react to changes.
Post a Comment for "How To Load Js From A Chrome Extension Popup"