Fragment Search

Fragment Search is a Greasemonkey script which allows people to create URLs which link to content within a page without having control over that page. Install the script. There's also an extension version too, thanks to the Greasemonkey Compiler.

Fragment identifiers in HTTP URIs have been historically used to link to a name or ID within a document's markup. For example, finds the HTML construct <a name="why-relicensing"> in the page in question.

This is historically true, although RFC 1738, the URL RFC, doesn't actually seem to mandate it. Fragment identifiers are specced at a high level in RFC 3986, but that doesn't say what they should be used for either. If you know where this is specced, please let me know.

But what do you do if the document doesn't have a name or ID where you want to link, and you don't have control of the document (as is the case for most people and most documents)? My suggestion is to extend the syntax of the fragment identifier using a character which is illegal in names/IDs ("!"), and which conforming browsers can use to trigger a textual search of the page contents.

So, for example,!s!design searches for the word "design" on the front page of this site. "#" starts the fragment identifier, "!" is the special character so it's obvious it's not a normal fragment identifier, "s" stands for search (there are several other things we want to do with the fragment identifier, like link fingerprints, so we need to keep them all separate) and the second "!" separates the command name from the instruction - i.e. what to search for, in this case "design".

If you don't want the first occurrence, you can put a number directly after the s - so !s10!operation searches for the tenth occurrence of "operation". Negative numbers search from the end instead of the beginning. The search is always case sensitive - after all, you are probably constructing the URL by cutting and pasting from the page itself.

Fragment search URLs are easy to construct - your browser will do most of the work for you. Go to a page which doesn't already have a fragment identifier, find the text you want to link to, copy it, edit the URL bar, type the magic #!s! and then paste. Note that, due to the way fragment identifiers and Greasemonkey work, you'll have to copy the resulting URL into a new window or tab to see it work. I suspect this limitation could be removed if support were built into the browser.

Once you've installed the script or extension, you can try it out some more using some other pages on

Original URL: