I am embedding a dynamic webpage in a popup. Currently its working and every time popup is loaded the webpage is loaded again, thus me losing the work i did on the webpage in popup. Though its fine, but i want that webpage remain loaded in background and i just show it in popup on click. to do this i copied complete code from my pop up page(script+html) to background.html. Now how should i access the page completely in popup and show directly(i want to show html also-from background page)
Thanks
Background pages are implicit pages which contain background scripts. A background script is a single long-running script to manage some task or state. It exists for the lifetime of your extension, and only one instance of it at a time is active.
forEach((tab) => { chrome. tabs. sendMessage( tab.id, youtPayload, function (response) { // do something here if you want } ); }); }); That's it!
Chrome 10 Now Lets Extensions Run in the Background.
Popups live in the same process (the extension process) as the background page, and one page can get the DOM Window of the other. A popup gets the background page by calling chrome.extension.getBackgroundPage()
. So every time you open the popup, just read and write to some variable on the background page, for example chrome.extension.getBackgroundPage().enteredData = "value";
.
Alternately, you can use HTML5 localStorage to store variables even after the browser is shut down; e.g. localStorage['enteredData'] = "value"
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With