bookmarklet: tooltips on links

M

Michael Hamm

Here's a neat bookmarklet for putting tooltips on links. I got the idea
a long time ago somewhere and made it much better than it started out.

javascript:dl=document.links;for(i=0;i<dl.length;i++)dl.title==""?dl.title=dl.href:dl.title.substring(dl.title.length-dl.href.length,dl.title.length)!=dl.href?dl.title+=": "+dl.href:dl.title=dl.title;df=document.forms;for(j=0;j<df.length;j++)df[j].title=df[j].action;void(null)

Broken up into readable lines, that's

javascript:dl=document.links;for(i=0;i<dl.length;i++)dl.title==""?
dl.title=dl.href:dl.title.substring(dl.title.length-dl
..href.length,dl.title.length)!=dl.href?dl.title+=": "+dl.
href:dl.title=dl.title;df=document.forms;for(j=0;j<df.length;
j++)df[j].title=df[j].action;void(null)

Copr. 2004 Michael Hamm.

Michael Hamm Since mid-September of 2003,
AM, Math, Wash. U. St. Louis I've been erasing too much UBE.
(e-mail address removed) Of a reply, then, if you have been cheated,
http://math.wustl.edu/~msh210/ Likely your mail's by mistake been deleted.
 
L

Lasse Reichstein Nielsen

Michael Hamm said:
Here's a neat bookmarklet for putting tooltips on links. I got the idea
a long time ago somewhere and made it much better than it started out.

javascript:dl=document.links;for(i=0;i<dl.length;i++)dl.title==""?dl.title=dl.href:dl.title.substring(dl.title.length-dl.href.length,dl.title.length)!=dl.href?dl.title+=": "+dl.href:dl.title=dl.title;df=document.forms;for(j=0;j<df.length;j++)df[j].title=df[j].action;void(null)


Cute, but I'm sure it can be done shorter :)

<URL: javascript:var D=document,d=D.links,h,i,c;for(i=0;i<d.length;i++){c=d;t=c.title;h=c.href;c.title=t?t.indexOf(h)>=0?t:t+": "+h:h;}d=D.forms;for(i=0;i<d.length;i++){d.title=d.action;}D=void 0; >

Except for the "void 0;" at the end, it even passes JSLint.
(There seems to be no way to make JSlint accept "void").
Broken up into readable lines, that's

Readable?!?
Shorter would be correct! :)

/L
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top