最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Open multiple tabs in Chrome via bookmarklet - Stack Overflow

programmeradmin1浏览0评论

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);

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);
Share Improve this question edited Jan 5, 2013 at 16:32 Nakilon asked Jan 5, 2013 at 16:04 NakilonNakilon 35.1k16 gold badges111 silver badges148 bronze badges 2
  • 1 Did you try setting a timer, say 10msec, so they appear to be separate opens. – user1637281 Commented Jan 5, 2013 at 16:06
  • @pure_code, finally I've got timeouts to work, thanks, that was it. – Nakilon Commented Jan 5, 2013 at 16:25
Add a ment  | 

2 Answers 2

Reset to default 4

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);

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.

发布评论

评论列表(0)

  1. 暂无评论