Completely lost on how to save extension popup window content

前端 未结 2 781
-上瘾入骨i
-上瘾入骨i 2020-11-28 13:53

I\'m pretty much lost on how to make the added contents of my popup window not disappear every time I open a new link or click it \"away\". I\'ve read about content script,

2条回答
  •  时光取名叫无心
    2020-11-28 14:29

    A popup reloads it's document every time it's closed/reopened. Instead, you should use a background page to preserve state.

    General way to do this is:

    1. communicate from popup to background to do something. I.e.: do an ajax request and store the result in a plain javascript object.
    2. do a get from the background page, to get the javascript object. Even though you close the popup, state is preserved in the background page.

提交回复
热议问题