How do I access the popup page DOM from bg page in Chrome extension?

前端 未结 3 2111
鱼传尺愫
鱼传尺愫 2021-02-08 14:14

In Google Chrome\'s extension developer section, it says

The HTML pages inside an extension have complete access to each other\'s DOMs, and they can invoke f

3条回答
  •  名媛妹妹
    2021-02-08 14:44

    can you discuss why you would want to do that? A background page is a page that lives forever for the life time of your extension. While the popup page only lives when you click on the popup.

    In my opinion, it should be refactored the other way around, your popup should request something from the background page. You just do this in the popup to access the background page: chrome.extension.getBackgroundPage()

    But if you insist, you can use simple communication with extension pages with sendRequest() and onRequest. Perhaps you can use chrome.extension.getViews

提交回复
热议问题