plugin to show anchors in an HTML page?

21

4

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.

BCS

Posted 2010-09-26T15:55:58.657

Reputation: 725

1

@rustyx -- see https://gist.github.com/inkarkat/cd1d40996a1f818dfc71 for a better version which supports h1 anchors

– Rich – 2015-10-19T11:05:15.990

1Thanks. 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 – 2013-02-28T11:18:35.287

@rustyx, I'm not finding any examples of how to do that. – BCS – 2013-02-28T15:46:19.217

Answers

9

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.)

Bavi_H

Posted 2010-09-26T15:55:58.657

Reputation: 6 137

1

This version of "show anchors" is much improved from that blog post: https://gist.github.com/inkarkat/cd1d40996a1f818dfc71

– Rich – 2015-10-19T11:04:34.753

I can't seem to make the second one work. – BCS – 2010-09-27T00:30:59.023

1

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: https://gist.github.com/LucasLarson/d5bd0881d8eb99d9fb254d28e7a315c4

– Lucas – 2018-10-29T22:55:45.620

6

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

therefromhere

Posted 2010-09-26T15:55:58.657

Reputation: 7 294

0

Display Anchors seems to be the most popular Chrome plugin.

Dan Csharpster

Posted 2010-09-26T15:55:58.657

Reputation: 129

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);})();

Gnubie

Posted 2010-09-26T15:55:58.657

Reputation: 2 371