Pop-up background page

I embed a dynamic webpage in a popup. Currently, it is working and every time a pop-up window loads, the web page loads again, so I lose the job I did on the web page in a pop-up window. Although this is great, but I want this webpage to remain loaded in the background, and I just display it in a popup. To do this, I copied the full code from my popup page (script + html) to background.html. Now, how should I fully access the page in the popup menu and show directly (I want to show html as well - from the background page)

thanks

+8
javascript google-chrome-extension
source share
1 answer

Pop-ups live in one process (extension process) as a background page, and one page can get another DOM window. The popup gets the man page by calling chrome.extension.getBackgroundPage() . Therefore, every time you open a popup, just read and write some variable in the background image, for example chrome.extension.getBackgroundPage().enteredData = "value"; .

Alternatively, you can use HTML5 localStorage to store variables even after closing the browser; for example localStorage['enteredData'] = "value" .

+13
source share

All Articles