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

[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 UTC