W3C home > Mailing lists > Public > www-annotation@w3.org > January to June 2001

bookmarklet: resubmission

From: Laurent Denoue <denoue@pal.xerox.com>
Date: Mon, 16 Apr 2001 10:50:02 -0700
Message-ID: <093736988B03D511BD91003048214B50B250@palxchange.pal.xerox.com>
To: "'www-annotation@w3.org'" <www-annotation@w3.org>
I sent this bookmarklet example last week but the mail came back...
So here is a repost.

With a bookmarklet, you can get the current selection in the browser window.
So you can attach the annotation to any string.

You will also need to browse frames in the document to find the frame where
the selection came from and then pick up the URL of this frame.

Here is an example with Internet Explorer (you can adapt this for netscape
also, replacing document.selection by document.getSelection; note that with
Netscape, I do not know DHTML enought to dynamically change the color of the
highlighted text... whereas it's easy with IE):
ion}else{encore=true;for(i=0;encore&&(i<this.length);i++){sel =
this.frames[i].document.selection;if (sel.createRange().text!="")
sel.createRange().text;sel.empty();if (txt=="")txt="<whole
document>";comment=prompt("New annotation for\n"+txt,"");alert("Attached

You might improve this example by getting some context to the selection or
make sure the string you've selected is unique in the document, or get the
ID of the nearest element in the document, etc.

Talking about XPointers to anchor annotations, I'm not sure that using IDs
is a good idea: users do not expect annotations to remain on the document if
the CONTENT has changed! Imagine you highlight a title in the CNN home page.
The next day, the title will be different, but you will still get your OLD
Of course, there might be cases when people want to explicitely attach
annotations to the structure of the document, although I cannot find
compelling examples. But in the general case, people attach annotations to

So you may use IDs in the document to help the algorithm locate those
annotations, but you should also use CONTENT (and in my opinion, CONTENT
should remain the main heuristic).
You could also read the paper from Microsoft "Robust Annotation Positioning
in Digital Documents." available at
Received on Monday, 16 April 2001 13:50:45 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 20:16:55 UTC