Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have a simple list of research links on a Chrome Extension:

<a href="http://www.example1.com" target="_blank">Research Link 1</a>
<a href="http://www.example2.com" target="_blank">Research Link 2</a>
<a href="http://www.example3.com" target="_blank">Research Link 3</a>

On any webpage, I could ctrl+click all three links, opening new tabs in the background. However, this doesn't seem to be the case with a Chrome Extension Popup. If you ctrl+click on a link, the extension closes the popup, which prevents you from clicking more than one link at any time.

I've tried an on-click chrome.tabs.create approach which is described in several other posts, but that seems similar to just clicking target="_blank" as it just opens a new tab with focus.

chrome.tabs.create({url: 'http://www.google.com'});

Is there any way to open a new tab without focus (ctrl+click), while still allowing the extension popup to remain visible in the current tab so that the user can click a second, third, or fourth link? That way the user doesn't have to rerun the extension several times, which takes time as it has to authenticate and query for the data all over again.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
894 views
Welcome To Ask or Share your Answers For Others

1 Answer

Yes, there is an option for create:

chrome.tabs.create({url: 'http://www.google.com', active: false});

I'm using it in one of my extensions exactly as you described.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...