在 Chrome 中一次打开多个链接作为新标签页 [英] Open multiple links in Chrome at once as new tabs
本文介绍了在 Chrome 中一次打开多个链接作为新标签页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试在 Google Chrome 的新标签页中一次打开多个链接,但失败了.
I'm trying to open multiple links at once in Google Chrome in new tabs but it fails.
问题:
- 被弹出窗口阻止
- 在用户允许弹出窗口后在新窗口而不是标签页中打开
<小时>
使用 this,我可以在 Firefox 中同时打开多个链接:
With this, I can open multiple links at once in Firefox:
<!DOCTYPE html>
<html ng-app="plunker">
<head>
<meta charset="utf-8">
<title>AngularJS Plunker</title>
<script>document.write('<base href="' + document.location + '" >');</script>
<link rel="stylesheet" href="style.css">
<script data-require="angular.js@1.2.x" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.17/angular.min.js" data-semver="1.2.17"></script>
<script src="app.js"></script>
</head>
<body ng-controller="MainCtrl">
<button ng-click="openLinks()">Open</button>
</body>
</html>
另外,我发现有人发现一种解决方法.
Also, I came across someone who found a workaround.
我尝试使用 setInterval
尝试单独打开链接,但没有成功.
I tried using setInterval
to try to open the links individually but it didn't work.
推荐答案
你可以在原生 JavaScript 中做到这一点:
You can do this in vanilla JavaScript:
<html>
<head>
<script type="text/javascript">
function open_win() {
window.open("http://www.java2s.com/")
window.open("http://www.java2s.com/")
}
</script>
</head>
<body>
<form>
<input type=button value="Open Windows" onclick="open_win()">
</form>
</body>
</html>
这是一个更特定于 Chrome 的实现(如果弹出窗口阻止程序给您带来困难):
Here is a more Chrome-specific implementation (if popup blockers are giving you difficulty):
var linkArray = []; // your links
for (var i = 0; i < linkArray.length; i++) {
// will open each link in the current window
chrome.tabs.create({
url: linkArray[i]
});
}
这里是一些文档:https://developer.chrome.com/extensions/tabs
这篇关于在 Chrome 中一次打开多个链接作为新标签页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文