简体   繁体   中英

Opening popup in new tab

So I recently implemented a chrome extension to grab images in an active tab and extract them to a popup for downloading. I would like to give users the option to view the popup window (including the extracted images) in a new Chrome tab.

However, since the popup is created dynamically by appending children to the body of my popup.html, I'm not sure how to pass the HTML for my popup to the new chrome tab.

I tried using chrome.tabs.create({url: chrome.extension.getURL('popup.html#window')});

as found at Open chrome extension in a new tab

but this doesn't seem to be working. Any suggestions?

I'm also developing a Chrome Extension that involves saving down a user's browser data.

Since each time an Extension opens a page (such as popup.html in your case) it opens a new instance of it, the pages and their relevant activity will be independent from each other.

In short you will have to implement some storage. The silver lining is it's pretty simple. Everything you need from manifest to example functions is here: https://developer.chrome.com/extensions/storage

In your case what I'd imagine you'd want to do is this: When you pass image urls to your popup page you also save them as items in an array in storage. Then your pop up page can load in the array as the list to set downloading (or preview depending on use case). Then either users can delete items from the array, or they are deleted programatically once downloaded.

I can't really be more specific without knowing exactly what your extension is trying to do or how it works, but hopefully that's enough to set you in the right direction.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM