'Window.open isn't working for multiple links in Google Chrome
I tested this in FF, work fine but not in Chrome. For single link, I found a hack which is using redirect, but I'm still looking for ways to open multiple links in new tabs in chrome.
http://plnkr.co/edit/zVaEFssH4o4qDycSUNGD?p=preview
$scope.openLinks = function(){
var urls = '';
angular.forEach($scope.links, function(item){
$window.open("redirect.html?" + item.link);
});
};
worth to mentiion, http://www.rapidlinkr.com/ doesn't work in chrome but working in FF.
Solution 1:[1]
Your window.open
seems to be working fine in Google Chrome, except for that fact that Chrome's pop-up blocker is blocking the new windows from opening up. There is no way to bypass this as far as I know unless the user allows the pop-up blocker to allow pop-ups on your website.
Solution 2:[2]
Chirag Bhatia, you can be opened, but you have to allow pop-ups.
Browsers don't allow you to open multiple pages at the same time, but you can open multiple pages at a time interval. for example at least in javascript it would be like this:
async function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
async function load() {
let links = [
"https://www.google.com/",
"https://www.facebook.com/",
"https://www.youtube.com/",
"https://www.instagram.com/",
"https://www.twitter.com/",
"https://www.linkedin.com/",
"https://www.pinterest.com/",
"https://www.github.com/",
"https://www.quora.com/",
"https://www.reddit.com/"
];
for (const link of links) {
window.open(link, "_blank");
await sleep(100);
console.log("Open another tab");
console.log(link)
}
}
load();
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Chirag Bhatia - chirag64 |
Solution 2 | Sho_Lee |