bookmarklet: tooltips on links

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Michael Hamm

    bookmarklet: tooltips on links

    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=d ocument.links;f or(i=0;i<dl.len gth;i++)dl[i].title==""?dl[i].title=dl[i].href:dl[i].title.substrin g(dl[i].title.length-dl[i].href.length,dl[i].title.length)! =dl[i].href?dl[i].title+=": "+dl[i].href:dl[i].title=dl[i].title;df=docum ent.forms;for(j =0;j<df.length; j++)df[j].title=df[j].action;void(nu ll)

    Broken up into readable lines, that's

    javascript:dl=d ocument.links;f or(i=0;i<dl.len gth;i++)dl[i].title==""?
    dl[i].title=dl[i].href:dl[i].title.substrin g(dl[i].title.length-dl[i]
    ..href.length,d l[i].title.length)! =dl[i].href?dl[i].title+=": "+dl[i].
    href:dl[i].title=dl[i].title;df=docum ent.forms;for(j =0;j<df.length;
    j++)df[j].title=df[j].action;void(nu ll)

    Copr. 2004 Michael Hamm.

    Michael Hamm Since mid-September of 2003,
    AM, Math, Wash. U. St. Louis I've been erasing too much UBE.
    msh210@math.wus tl.edu Of a reply, then, if you have been cheated,
    http://math.wustl.edu/~msh210/ Likely your mail's by mistake been deleted.
  • Lasse Reichstein Nielsen

    #2
    Re: bookmarklet: tooltips on links

    Michael Hamm <msh210@math.wu stl.edu> writes:
    [color=blue]
    > 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=d ocument.links;f or(i=0;i<dl.len gth;i++)dl[i].title==""?dl[i].title=dl[i].href:dl[i].title.substrin g(dl[i].title.length-dl[i].href.length,dl[i].title.length)! =dl[i].href?dl[i].title+=": "+dl[i].href:dl[i].title=dl[i].title;df=docum ent.forms;for(j =0;j<df.length; j++)df[j].title=df[j].action;void(nu ll)
    >[/color]

    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[i];t=c.title;h=c. href;c.title=t? t.indexOf(h)>=0 ?t:t+": "+h:h;}d=D.form s;for(i=0;i<d.l ength;i++){d[i].title=d[i].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").
    [color=blue]
    > Broken up into readable lines, that's[/color]

    Readable?!?
    Shorter would be correct! :)

    /L
    --
    Lasse Reichstein Nielsen - lrn@hotpop.com
    The content of this message is hereby placed into the public domain.

    Comment

    Working...