Access window object from a background Chrome extension

前端 未结 1 1291
逝去的感伤
逝去的感伤 2021-01-02 19:22

I want to access the properties of a window object from a background script. I have this in manifest.json:

{
    \"..\": \"..\",
           


        
1条回答
  •  盖世英雄少女心
    2021-01-02 19:48

    You can't. The extension's background page runs in one process, while the tab that was updated runs in a separate process. Different processes can't share objects, so you can't directly access the window object of a tab from an extension's background page. You have to use a content script to get extension code to run inside the tab's process.

    0 讨论(0)
提交回复
热议问题