Nakilon
Nakilon

Reputation: 35074

Open multiple tabs in Chrome via bookmarklet

I'm making bookmarklets for my personal use, and some of them should open 2-3 tabs at once. But currently Chrome dissalows to open multilple tabs with one click, blocking the second, third and the rest of window.opens which I'm trying to execute.

I understand, that it's something about security and avoiding of eternal loops, but I need to open windows in just one iteration. I would like to make Chrome sure, that everything going to be fine and stop that annoying blocking, because extra clicks for allowing pop-ups on each website, while their number isn't limited, makes my bookmarklets not so useful at all.

Already tried this:

setTimeout(function(){window.open(url1)}, 500);
setTimeout(function(){window.open(url2)}, 500);

Upvotes: 6

Views: 6059

Answers (2)

user1637281
user1637281

Reputation:

They both open at the same(or close to) time with that code, change the delay or embed one in the other.


    setTimeout( function(){ window.open(url1) }, 10);
    setTimeout( function(){ window.open(url2) }, 20);
    setTimeout( function(){ /* any other code with window.open() */ }, 30);

Upvotes: 4

Adam Hopkinson
Adam Hopkinson

Reputation: 28795

Chrome runs each tab as a separate sandboxed process - when you click a bookmark, it can only take action within that tab.

That leaves you with the option of opening the second tab from the html/js of the first, but this will be blocked by the popup blocker unless it is prompted by a user action.

Upvotes: 1

Related Questions