W3C home > Mailing lists > Public > www-archive@w3.org > August 2003

Re: Bookmarklet to show anchors and ids in a DOM Level 1 compliant browser

From: Dominique HazaŽl-Massieux <dom@w3.org>
Date: 28 Aug 2003 09:44:25 +0200
To: www-archive@w3.org
Message-Id: <1062056666.24848.40.camel@stratustier>
[Follow-up on
http://lists.w3.org/Archives/Public/www-archive/2002Jul/0005.html ]

This bookmarklet makes appear an image of anchor after every tag with an
id or an anchor with a name; this image gives the link to the given
anchor:
javascript:(function(){var i,n,a,j,l;b=document.getElementsByTagName('*');for(i=0;i<b.length;++i){a=b[i];if(a.id||(a.tagName=="A"&&a.name)){j=document.createElement("img");j.src="http://www.w3.org/2003/08/anchor";j.style.border="none";j.alt="";if(a.id){n=a.id;}else{n=a.name;};if(a.tagName!="A"){l=document.createElement("a");}else{l=a;};l.href="#"+n;l.appendChild(j);if(a.tagName!="A"){a.appendChild(l);};l.style.border="1px solid black";}}})();

Note that it doesn't work in Internet Explorer before version 6.0 due to
the lack of interpretation of document.getElementsByTagName('*')

(the only change compared to the previous version is to use a www.w3.org
image rather than an image from my personal site).

Dom
-- 
Dominique HazaŽl-Massieux - http://www.w3.org/People/Dom/
W3C/ERCIM
mailto:dom@w3.org

Received on Thursday, 28 August 2003 04:02:28 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 7 November 2012 14:17:32 GMT