Linking to (Almost) Any Block Element of (Almost) Any Web Page
by Bob DuCharme
Related link: http://www.snee.com/addids
(The following is the introduction from the web page at the URL shown above; see the web page for information on how to use the CGI that does this.)
In the early days of the web, you could only link to a specific
point within a web page if that point had an a element with a
name attribute. Recent releases of the Mozilla, Internet
Explorer, and Opera web browsers, however, let you link to any element that has
an id attribute. (More on this in a weblog
posting I did.) Hopefully, more and more web development tools will
start adding id attributes to more block elements; I'm
trying to get into the habit of doing it to everything I
Meanwhile, I've written a CGI script named addids.cgi ("add IDs") that creates a temporary
copy of any web page you pass to it, with IDs added to block elements
so that you can create links to any block element you like in that
temporary copy. For a web page that doesn't change much (not, for
example, the home page of a newspaper's web site), nearly all
generated IDs will be the same every time a temporary copy is
generated. This means that you can look at a copy created by
addids.cgi, create a URL that links to a specific point within that
copy, and send that link to someone else with reasonable confidence
that it will show them the same point in the document.
A few random tests show that it works with some slick commercial sites (I linked to stories in the archives so that the examples would last longer): The BBC ("The varying hotel guests in each episode...") , Rolling Stone ("On 1971's Gets Next to You..." ) and a Vignette Storyserver-generated Time Magazine article ("Ethiopia: Tackling terror in East Africa." Scroll up for slickness.) For a layout so complex that the CGI messes it up (for example, Wired) there may be a "Print" version of the same story that's easier to link to ("Paper modeling reached the zenith..."). I found that it doesn't always work properly with IE 6.0 under Windows, but it seems to work fine with Firebird .7, Mozilla 1.5, and Opera 6.1 under Windows and IE 5, IE 5.1, Safari 1.0 under OS X.
How did it work for you?
Your algorithm - line-by-line checksums - has a couple of problems. A good example of something thats stinkingly broken with it is here:
Not only do the checksums in the page you reference change; the URL itself does, because it's from a transaction-oriented session that carries state information about the session right there in its URL. This URL won't work for someone trying to use it in another time and place, period, so the inability to let another person link to a point within that page can't be blamed on something in addids.cgi. You mentioned that the link might be "already broken by the time you see it"--the URL was designed to only work once for one person!
"This URL won't work for someone trying to use it..."
Is that browser understand something in HTML? Everything i done that work under any browser has always fail in that one for the first experiment after you have to make it work under explorer. The most of the time is spend on hating Bill.