John Tropea at Library Clips was asking if anyone knew of a bookmarklet that would generate link text to open in a new window. I thought I could figure that out based on the tagging bookmaklets I’d fidled with before (see also the screen cast there if bookmarklets in general could use clarification.)
So here’s that bookmarklet, you can probably figure out how to use it.
Here’s what the code looks like, displayable thanks to John’s recommended service centricle.com. (I just used the bookmarklet to use that link – hooray!
<a href="javascript:(function(){var%20a=”;var%20t=prompt
(‘Enter%20URL%20without%20http://’,”);var%20tr=t.split(‘%20′);
for(var%20i=0;i%3Ctr.length;i++){if(i%20%3E%200){a+=’,%20′;}a+
=’%3Ca%20href=’+unescape(‘%22’)+’http://’+tr[i]+unescape(‘%22’)+
‘%20target=’+unescape(‘%22’)+’blank’+unescape(‘%22’)+’%3E’+tr[i]+
‘%3C/a%3E’;};prompt(‘Copy%20this%20code,%20press%20OK,%20
then%20paste%20to%20your%20blog%20entry:’,a);})
()" rel="nofollow">NewWindow</a>
So obviously this is only going to be useful in some circumstances. You’re lined text will read marshallk.com but I’m often ok with that. A real developer could make this more sophisticated, but for now I think it’s pretty darned handy. Heck, I’ll bet with a little more time I could add another field so you can put in your text and then what you want it to link to. Anyone else faster at this than I am though?
Technorati Tags: linking, bookmarklets, HTML, javascript, hacks