Return to Snippet

Revision: 30111
at August 7, 2010 23:39 by andrew8088


Initial Code
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(); }}()); 
*/

Initial URL

                                

Initial Description
#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

Initial Title
Open Selected Links in New Tabs

Initial Tags

                                

Initial Language
JavaScript