A lot of people have asked me about my implementation of footnotes.1 I have a love-hate relationship with footnotes. I like to use footnotes, because they allow me to remove stuff that isn’t directly relevant to the text I’m currently writing, while still keeping the information around in case anyone is interested. On the other hand, footnotes are a usability nightmare, yanking you out of your place in the text to a completely different place, and then back up. They are an interruption.
So I figured that it would be a good idea to show the content of a footnote as soon as you indicate that you are interested in the footnote. Namely, when you move the cursor over the footnote symbol.2 This allows footnotes to work on devices that don’t support mouse hovering3, because you can still jump to a footnote via its link, but it removes the necessity of having to click on a footnote link for most people.
Some people have asked whether they can use my code for their own site.4 Sure, although it is unlikely that you will be able to use it without any changes. Here you go:
Basically, I first collect all footnote links and bind mouseover and mouseout event handlers to them. The mouseover handler searches for the proper footnote based on the footnote link’s id, and then shows a div with the footnote’s HTML. The mouseout handler removes that div again. Moving the mouse from the footnote link to the footnote popup stops the mouseout handler’s animation so that the popup sticks around in case you want to click on a link inside it; leaving the popup triggers the mouseout handler again. Depending on how your footnotes are rendered, you will need to change the setup function to find the footnote links on your site, and you will need to change the footnoteover function to find the proper footnote’s content for each footnote link. You can add a #footnotediv rule to your CSS in order to style it.
I have tested this with Safari and Firefox.
A number of people have asked me to tell John Gruber to use the same footnote system for Daring Fireball. I’m not sure why people think that I would be able to convince him to change his site; I highly doubt he would listen to me. However, due to surprisingly popular demand, I have created a very simple, barebones version of my script that works with his site. I’ve made it into a bookmarklet. Simply drag this to your bookmarks bar:
Once Daring Fireball has fully loaded, you can click on the bookmarklet to add the mouse event handlers to the bookmark links. After doing so, you should be able to hover over a footnote link to see its corresponding text.
Again, I have tested this in Safari and Firefox. In case you’re curious, here’s the code:
And some people have asked me about a license for this piece of code. I think it’s far too short to get its own license, so I’m relinquishing any copyright claims. Consider the code to be public domain. No attribution is necessary.
If you require a short url to link to this article, please use http://ignco.de/275