Flow of events:
- When the page is loaded, and an anchor event listener exists, the
anchor event will be fired after the load event. If there is no anchor
in the URL, the event.anchorName property will be an empty string.
- When an anchor link is clicked, the anchor event listener (if exists)
will be fired
- The event handler can get the name of the anchor via event.anchorName
(which will contain the string after the hash)
- If the return value from the handler is true, the traditional form of
operation (the jumping to the anchor) will occur next; otherwise, that
step is skipped.
- The UA should act as if the navigation has gone forward a page (add
history, etc).
- If the user navigates back and the previous page happens to be the
same page but a different anchor, the anchor event again will be fired
as if the previous anchor was freshly navigated to. The same logic
applies to navigating forward.
sounds good, and logical when compared with anchor and button onclick
for example.
to clarify, where would the event be attached by default? document or
window? i.e. would i
function myonAnchor( e )
{
if( e.anchorName )
switch( e.anchorName )
{
...
default:
return true;
}
}
document.onAnchor = myonAnchor;
---
Ric Hardacre
http://www.cyclomedia.co.uk/