4

Double-hash search fragments

 3 years ago
source link: http://rachelbythebay.com/w/2012/01/28/hashsearch/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Double-hash search fragments

Sometimes I find myself wanting to send someone to a particular part of a web page. More often than not, there isn't an anchor inside the page where I want it to be, or at all. I might be able to get close with a #foo stuck on the end of the URL if such an anchor exists, but otherwise I'm out of luck.

Telling someone to go to page X and then search for "foo" is annoying, too. It isn't the sort of thing which translates well to people who are privileged enough to just use this tech and don't have to be burdened with the details of how it really works. After all, is it ctrl-f, alt-f, cmd-f, or something else entirely? Also, how much will they have to type to get a unique string which will drop them right on that exact spot?

This is madness, and so I present my half-baked idea of the day: the double-hash search fragment.

Let's say I want you to go to a given page and notice the part which says "This is madness", but there's no internal anchor which would match. Instead, I send you to this URL:

http://example.com/whatever##This is madness

If your browser knew about this convention, then it would search in the page once it loaded and jump down to that location. If it didn't, then it would try to seek down to an anchor called "#This is madness", which of course would match nothing. In that case, it would just stay at the top as usual, and the user would have to search manually.

I imagine someone might also hack up some JS to search-and-jump for browsers which don't support it natively. That would allow sharing this feature with more of the world if a site owner really wanted it to happen.

Assuming this happens, there's only one piece left: the ability to generate such a link on a given page. I imagine this would work from a right-click context menu. You'd just click at the point you want to reference, and the browser should sift through the page and find a unique sequence which would match there and nothing else before it.

Basically, it would do the same thing you do now when you want to say "search for X" but then have to manually check to make sure it's not an ambiguous request.

This could remove a fair amount of cruft from web pages.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK