简体   繁体   English

在新标签页中打开弹出窗口

[英]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. 因此,我最近实施了chrome扩展程序,以在活动标签中抓取图像并将其提取到弹出窗口中以进行下载。 I would like to give users the option to view the popup window (including the extracted images) in a new Chrome tab. 我想让用户可以选择在新的Chrome标签中查看弹出窗口(包括提取的图像)。

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. 但是,由于弹出窗口是通过将子代追加到popup.html的正文中而动态创建的,因此我不确定如何将弹出窗口的HTML传递到新的chrome选项卡。

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

as found at Open chrome extension in a new tab 在新标签页中的“打开chrome扩展程序”

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. 我还在开发一个Chrome扩展程序,该程序涉及保存用户的浏览器数据。

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. 由于扩展程序每次打开页面(例如您的情况下的popup.html)都会打开它的新实例,因此页面及其相关活动将彼此独立。

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 从清单到示例功能所需的一切都在这里: 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. 在您的情况下,我想做的是:将图像url传递到弹出页面时,您还将它们另存为数组中的项。 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. 如果不能确切地知道您的扩展程序正在尝试执行的工作方式或工作方式,我真的不能更加具体,但是希望这足以使您朝正确的方向发展。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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