一次在Chrome中打开多个链接作为新标签 [英] Open multiple links in Chrome at once as new tabs
问题描述
问题:
$ b 我试图在Google Chrome浏览器中的新选项卡中一次打开多个链接,但它失败。 $ b
- 通过弹出窗口阻止
- 在用户允许弹出窗口
<!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 =stylesheethref =style.css>
< script src =app.js>< / script>
< / head>
< body ng-controller =MainCtrl>
< button ng-click =openLinks()>打开< /按钮>
< / body>
< / html>
另外,我遇到了发现解决方法。
我试过使用 setInterval
尝试单独打开链接,但它不起作用。 可以在香草JavaScript中做到这一点:
< html>
< head>
< script type =text / javascript>
函数open_win(){
window.open(http://www.java2s.com/)
window.open(http://www.java2s.com/ )
}
< / script>
< / head>
< body>
< form>
< input type = button value =Open Windowsonclick =open_win()>
< / form>
< / body>
< / html>
这是一个更具体的Chrome实现(如果弹出式窗口拦截器给你带来困难):
var linkArray = []; //你的链接
for(var i = 0; i< linkArray.length; i ++){
//将打开当前窗口中的每个链接
chrome.tabs.create({
url:linkArray [i]
});
}
以下是一些文档: https://developer.chrome.com/extensions/tabs
I'm trying to open multiple links at once in Google Chrome in new tabs but it fails.
Problems:
- Blocked by popup
- Open in new windows instead of tab after the user allowed the popup
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.
I tried using setInterval
to try to open the links individually but it didn't work.
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>
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]
});
}
Here is some documentation: https://developer.chrome.com/extensions/tabs
这篇关于一次在Chrome中打开多个链接作为新标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!