我需要在单个窗口上打开多个选项卡,单个链接的新窗口实例不会成为问题,但当涉及 20 个以上(这是我的情况)时,那么 20 个以上新窗口确实是一个问题,所以我需要找到一个解决方案,代码必须在 chrome 上运行,仅在我的情况下,我有 35 个链接存储在数组中。我正在使用 for 循环读取数组,并使用 window.open()
在新选项卡中打开链接
我只能使用 JavaScript 来实现此目的。我正在开发一个定制的 chrome 扩展。
我发现,在 Google Chrome 中使用 window.open()
打开同一窗口的不同选项卡中的多个链接时,它仅成功打开前 24 个窗口,而忽略了其余窗口。
我需要找到一种只需单击一下即可立即打开所有链接的方法。
有一些可用的 Google Chrome 扩展,其工作原理如下
LinkClump
此扩展成功打开同一窗口的不同选项卡中的所有选定链接。我正在尝试修改它的工作方式以适合我的。
同时,如果有人能得到任何解决方案,我们非常欢迎。
I need to open multiple tabs on a single window, new window instance for a single link will not be a problem but when it comes to 20+ (which is my case) then 20+ new windows are really a problem, so I need to find a solution, the code has to run on chrome only in my case I have 35 links stored in an array. I am reading array using a for loop and opening links in new tabs using window.open()
I can use only JavaScript for this. I am developing a customized chrome extension.
I found out that while using window.open()
to open multiple links in different tabs of a same window in Google Chrome, it succeeds in opening only first 24 windows and left out the rest.
I need to find out a way to open all the links at once with a single click.
There are some Google Chrome Extensions available which work like this like
LinkClump
This Extension successfully open all selected links in different tabs of a same window. I am trying to modify its working to suit mine.
Meanwhile, if anyone can get any solution, he/she is most welcome.
发布评论
评论(3)
我不确定您是否希望在新窗口中打开链接,因此我包含了两种可能性;
同一窗口
chrome.tabs 文档
新窗口
chrome.windows 文档
无论您使用哪种方法,都需要声明 tabs 扩展程序清单中的权限。
I wasn't sure if you wanted the links to be open in a new window or not so I've included both possibilities;
Same Window
chrome.tabs documentation
New Window
chrome.windows documentation
Regardless of which approach you use you will need to declare the tabs permission in your extension's manifest.
您可以使用链接的
target="_blank"
属性在新选项卡中打开相应页面。You can use
target="_blank"
attribute of a link for opening the corresponding page in new tab.解决方案:
使用setTimeout! 时间值越来越多
这将克隆当前选项卡 50 次,即使在 Chrome 中也是如此!不幸的是,在新的Windows而不是新的选项卡中。愚蠢的铬:-)
Solotion:
Use setTimeout! With more and more time values
This will clone the current tabs 50 times, even in Chrome! Unfortunately, in new Windows instead of new tabs. Silly Chrome :-)