If you go to http://www.deviantart.com/ and wait a few seconds so the javascript loads under the hood you can click a link and instead of going to the link you’ll go to #/someId. You can hit back/forward. I believe i saw similar behavior on other sites but without using # in the url.
How do i do an event like make something visible or collapse something and undo (or redo) the event with the back/forward button?
It’s making use of pushState. Here is a sample page making use of this technique.
If you want to implement this, I really recommend using history.js. It covers some cross-browser issues that you’ll otherwise run in to.