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 中一次打开多个链接作为新标签页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在 Chrome 中一次打开多个链接作为新标签页
基础教程推荐
- 如何使用 CSS 显示和隐藏 div? 2022-01-01
- 每次设置弹出窗口的焦点 2022-01-01
- Javascript 在多个元素上单击事件侦听器并获取目标 2022-01-01
- Node.js 有没有好的索引/搜索引擎? 2022-01-01
- jQuery File Upload - 如何识别所有文件何时上传 2022-01-01
- 如何在特定日期之前获取消息? 2022-01-01
- 为什么我在 Vue.js 中得到 ERR_CONNECTION_TIMED_OUT? 2022-01-01
- WatchKit 支持 html 吗?有没有像 UIWebview 这样的控制器? 2022-01-01
- 如何使用sencha Touch2在单页中显示列表和其他标签 2022-01-01
- 什么是不使用 jQuery 的经验技术原因? 2022-01-01
