Open Text Links // Bookmarklet
Join the DZone community and get the full member experience.
Join For FreeOpen Text Links : this bookmarklet collects strings of the form http://... or https://... in the user-selected text and then open them all in new windows. tested with Firefox 1.5 and IE 6.
The code
javascript:(function(){var w=window,d=document,rg=/\bhtt(p|ps)\:\/\/\S+\b/ig,gS='getSelection';var links=(''+(w[gS]? w[gS]():(d[gS]?d[gS]():d.selection.createRange().text))).match(rg);if(confirm(links.join('\n')))for(var i=0,len=links.length;i
Code with comments
javascript:(function(){
var w=window,d=document,rg=/\bhtt(p|ps)\:\/\/\S+\b/ig,gS='getSelection';
// set links = the list of strings of the form http:/... or https:/... in the selected area
var links=(''+(w[gS]? w[gS]():(d[gS]?d[gS]():d.selection.createRange().text))).match(rg);
// if user confirms the list then open them all in new windows and then alert 'done'.
if(confirm(links.join('\n')))
for(var i=0,len=links.length;i
Links
Bookmarklet
Opinions expressed by DZone contributors are their own.
Comments