Getting and Setting anchors with JavaScript

Something I've been playing with recently that's not very well documented is using JavaScript to retrieve and to update the current page anchor from a URL.

It's very simple to do. In order to retrieve the page anchor (i.e. get test from http://chris-miller.org/88#test:

var anchor = self.document.location.hash.substring( 1 );

Setting the anchor to update, for example to http://chris-miller.org/88#newAnchor it can be achived using:

self.document.location.hash = "newAnchor";

Very useful for creating permalinks to AJAX loaded content or JS popups.
- Chris