24

I often find my self looking for a link that will drop me in the middle of a web page. Often I find that the page has the needed <a name='foo'> tags but no easy way (e.g. a table of contents) to find them. Does anyone know of a plugin that shows where/what those tags are?

I'd need chrome but answered for others would be useful.


FWIW: this is what I ended up using:

javascript:(function(){var i,n,a;as=document.anchors;for(i=0;i<as.length;++i) {a=as[i];n=a.name;a.appendChild(document.createTextNode("#"+n));a.style.border="1px solid";;a.href="#"+n;}})();

Take that, and put it as the link address in a bookmark.

3
  • 1
    Thanks. Too bad this doesn't seem to work with frames or heading anchors (it is possible to anchor on an H1, for example, not just on an <A>)
    – rustyx
    Commented Feb 28, 2013 at 11:18
  • @rustyx, I'm not finding any examples of how to do that.
    – BCS
    Commented Feb 28, 2013 at 15:46
  • 1
    @rustyx -- see gist.github.com/inkarkat/cd1d40996a1f818dfc71 for a better version which supports h1 anchors
    – Rich
    Commented Oct 19, 2015 at 11:05

4 Answers 4

8

Web Development Bookmarklets has a JavaScript bookmarklet called named anchors that will insert links at each <a name=""> anchor. To use the bookmarklet, add it to your favorites menu or links bar. Then, on any page, click on the "named anchors" bookmark to insert links into the current page. However, it doesn't work on Wikipedia or other sites that use id attributes of tags as anchors.

Edit:
Show Anchors is a more modern bookmarklet that shows both <a name=""> and id elements with an anchor icon. The icon is embedded in the bookmarklet as a data: URL, so it might not work in older browsers. (The bookmarklet link is at the very top of the post.)

4
  • I can't seem to make the second one work.
    – BCS
    Commented Sep 27, 2010 at 0:30
  • 1
    This version of "show anchors" is much improved from that blog post: gist.github.com/inkarkat/cd1d40996a1f818dfc71
    – Rich
    Commented Oct 19, 2015 at 11:04
  • 3
    I made a version I like even better. Instead of an image of an anchor, I made the bookmarklet display # followed by the name or id of the element: gist.github.com/LucasLarson/d5bd0881d8eb99d9fb254d28e7a315c4
    – Lucas
    Commented Oct 29, 2018 at 22:55
  • 1
    the version by @Lucas works for me in Safari where as the others done.
    – Alex
    Commented Jun 13, 2021 at 13:01
6

The Show Anchors 2 add-on does just that on Firefox.

1
  • The link is dead. I couldn't find the plugin "Show Anchors 2" elsewhere. Seems like it was deleted or renamed.
    – Socowi
    Commented Aug 27, 2021 at 9:10
0

Display Anchors seems to be the most popular Chrome plugin.

0

BCS's answer adapted to work with frames:

javascript:(function(){function f(e){var i,n,a;as=e.anchors;for(i=0;i<as.length;++i){a=as[i];n=a.name;a.appendChild(e.createTextNode('\u2693'+n));a.style.color='#fff';a.style.background='#666';a.style.borderRadius='5px';a.href='#'+n;}}if(window.frames.length)for(var i=0;i<window.frames.length;++i)f(window.frames[i].document);else f(document);})();

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .