Is there a way to bind a function to the change of the current URL of the page?

I want to use it when an id is added to the URL. Example:

http://ferhrosa.pfsistemas.com/#posts changend to http://ferhrosa.pfsistemas.com/#tags

In this case, there is no request to the server and the page is not being loaded again, so I can't use the "onload" event from body too, for exemple.

I don't want to bind a function to the "onclick" event of links too, because in this way it doesn't going to work when the user changes the URL manually.

Example sites:
www.casualcollective.com
www.orkut.com