/ Published in: JavaScript

#Notes\r\n\r\n* Opens all the links in a selection in new tabs (or windows, depending on your browser configuration)\r\n* I want it to open the tabs in the background, but window.focus() only keeps the current tab at the front in Safari. Let me know if you have a solution
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
var a = document.querySelectorAll('a[href]'), l = a.length; if (window.getSelection&&window.getSelection().containsNode) { for ( var i = 0; i < l; i++) { if (window.getSelection().containsNode(a[i],true)) { window.open(a[i].href); } } window.focus(); } /* Bookmarklet: javascript:(function(){var a = document.querySelectorAll('a[href]'),l=a.length;if (window.getSelection&&window.getSelection().containsNode){for(var i = 0; i < l; i++){if(window.getSelection().containsNode(a[i],true)){ var w = window.open(a[i].href); }} window.focus(); }}()); */
Comments
