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

Categories

0 votes
418 views
in Technique[技术] by (71.8m points)

javascript - open a new browser tab in background programmatically

Problem

I'm using a web-based feed reader, TinyTinyRSS. When sifting through the feed lists, I'd like to open interesting articles in new tabs - but in the background, because I want to read them only after I went through all feed items.

TT-RSS has a shortcut key "o" to open the article in a new tab, but it opens the tab in the foreground (window.open).

The question is now: To fix TT-RSS, I need to know how to open a background tab from javascript. It'd be awesome if the solution worked across browsers (Firefox, Chrome, Opera, Safari).

I understand the privacy issue about that, but having it enabled for one certified webpage is ok.

Existing (bad) solutions

Firefox

In about:config, set browser.tabs.loadDivertedInBackground to true. This opens all the tabs from pages in the background, which is not what I want - I want it only for the one application/website.

Chrome

Chrome has a shytab extension. Works in chrome only and is for all pages.

See Question&Answers more detail:os

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

1 Answer

0 votes
by (71.8m points)

Back when popup ads were a thing, this was called a "popunder" window. Popunders used to do something like this:

var popupWindow = window.open(...);
popupWindow.blur();
window.focus();

Popup blocking kind of messed around with what does and doesn't work, though- your mileage may vary.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...