/ Published in: JavaScript
When there's a URL on a page that's not a link, just highlight it and click this bookmarklet. The URL will open in a new window.
If there are multiple selections (e.g., if you've selected something in each of two frames on the page), they will each be opened in a new window.
[Open Link](javascript:(function(){function T(f){try{if(f.getSelection)return f.getSelection().toString();if(f.document.selection)return f.document.selection.createRange().text}catch(e){}return ""}function A(f){var a=[];var t=T(f);if(t)a.push(t.replace(/^\s+|\s+$/g,""));for(var i=0;i<f.length;i++){a=a.concat(A(f[i]))}return a}var a=A(window.top);for(var i=0;i<a.length;i++){if(!/^https?:\/\//.test(a[i])) a[i]="http://"+a[i];window.open(a[i])}})() "Drag this into your bookmarks!")
If there are multiple selections (e.g., if you've selected something in each of two frames on the page), they will each be opened in a new window.
[Open Link](javascript:(function(){function T(f){try{if(f.getSelection)return f.getSelection().toString();if(f.document.selection)return f.document.selection.createRange().text}catch(e){}return ""}function A(f){var a=[];var t=T(f);if(t)a.push(t.replace(/^\s+|\s+$/g,""));for(var i=0;i<f.length;i++){a=a.concat(A(f[i]))}return a}var a=A(window.top);for(var i=0;i<a.length;i++){if(!/^https?:\/\//.test(a[i])) a[i]="http://"+a[i];window.open(a[i])}})() "Drag this into your bookmarks!")
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
javascript:(function(){function T(f){try{if(f.getSelection)return f.getSelection().toString();if(f.document.selection)return f.document.selection.createRange().text}catch(e){}return ''}function A(f){var a=[];var t=T(f);if(t)a.push(t.replace(/^\s+|\s+$/g,''));for(var i=0;i<f.length;i++){a=a.concat(A(f[i]))}return a}var a=A(window.top);for(var i=0;i<a.length;i++){if(!/^https?:\/\//.test(a[i])) a[i]="http://"+a[i];window.open(a[i])}})(); //Here it is expanded so you can read it: javascript:(function(){ function T(f) //get the selected text in frame f { try{ if(f.getSelection) return f.getSelection().toString(); if(f.document.selection) return f.document.selection.createRange().text; }catch(e){} //if the frame is in another domain return ''; } function A(f) //get the selected text in frame f and its children { var a = []; var t = T(f); if(t) { a.push(t.replace(/^\s+|\s+$/g, '')); } for(var i=0; i<f.length; i++) //for each child frame { a = a.concat(A(f[i])); } return a; } var a = A(window.top); for(var i=0; i<a.length; i++) { if(!/^https?:\/\//.test(a[i])) a[i] = "http://"+a[i]; window.open(a[i]); } })();