How many times have you told a friend or colleague "Go to http://example.com/some/doc and search for XXXX" ? I do it a lot actually. Ideally web pages should identify significant sections of a web page with identifiers (id="foo") so that you can link to http://example.com/some/doc/#foo, but the problem is that not everyone follows this practice. In fact, there are a lot of big specification documents where you'd like to point someone to a specific paragraph to save someone time and encourage them to actually visit the link and read it. This becomes increasingly important as the mobile web accelerates and small screens with harder-to-use keyboards become more prevalent. I hope this Firefox extension will help.

Tonight I updated my Firefox extension, FXPointer, so that you can right-click on some web page text and get the XPointer element link that will drive people directly to it. This is the first time the extension comes close to being semi-usable, so I thought I should start to get the word out. It's very similar to Doug's excellent Idiri extension, except that FXPointer tries to use the XPointer specification for HTML documents. Thus, it will allow you to link directly to any element in a web page.

Truth be told, Firefox already supports XPointer to some degree on true XML documents. Tragically, it doesn't work with XHTML documents (see Bug 235409). Worse yet, the amount of HTML on the web vastly outweighs the amount of XHTML, meaning that XPointer will never really reach critical mass without a boost in the HTML direction.

For Opera users, please see Jeroen's web page that gives you some User JavaScript to get things going. This means that you can get some XPointer/HTML functionality on two of the four big browsers out there.

Anyway, I plan to start using these more-specific links going forward. If you don't have XPointer support, you'll just get a less-specific link. I'll try to make improvements that degrade even more gracefully in the future.

Some future plans that may or may not transpire:

  • Support for the xpointer scheme so you can use XPath and search strings (probably less brittle)
  • Support for SVG's XPointer-friendly scheme svgView
  • Some configuration of the context menu

If you want to submit patches, download the .xpi, unzip it and hack away.

FXPointer does its best to use IDs where it can, so this is less brittle than it seems, but I still wouldn't recommend this for any dynamic web pages with wildly changing DOMs. Of course the ultimate would be to support the xpointer scheme in some way such that people can use XPath and string searches.

If you think this extension is useful, please help lobby for native XPointer/HTML support in browsers.

§402 · October 30, 2007 · Firefox, Opera, Software, Technology, Web, XML · Tags: · [Print]

4 Comments to “FXPointer – Link Exactly”

  1. Thanks for the work, I downloaded and installed, and spreaded out for people whom I will send some XPointered links.

    On the extension, can you make the added context menu entry be in the same group as “Copy link location”?

    I have some comments on this post’s text and the FXPointer’s page:

    Of course the ultimate would be to support the xpointer scheme in some way such that people can use XPath and string searches.

    I would expect that link to point to some XPointer spec or other, not this very page 🙂

    For instance, this link should send you directly to the NodeList interface section of that document.

    I think the link should point to some part of XPointer framework spec, which would 1) demonstrate that FXPointer works with HTML, 2) qualify the “that document” pointer more coherently

  2. David says:

    Don’t the major browsers support XPath ?

    Thus it should be even simpler to implement than the this opaque element scheme…(?)

  3. David,

    You are right that some major browsers support XPath (Firefox included). However, the way I understand it, the xpointer() scheme adds several functions for string searches, etc. This is non-trivial to implement and the element() scheme was much simpler.

    Jeff

  4. Jeroen says:

    David, both the extension and the userscript have some support for the XPointer scheme. They support the XPath that’s available in the browser it runs in. Two of my tests use it.

    The XPointer scheme extends the XPath language with useful custom functions. The current browser APIs to XPath don’t allow you to define your own functions, so there’s no easy way to emulate these functions.

    The implementation of the element scheme also converts the element notation into an XPath query, btw.