You are missing a closing );
at the end of the second event handler assigment.
$(window).on('hashchange', function () {
'...';
}); //<= here you had only }
Other than that, it seems to work fine. Unless you are using IE7 of course, which does not support onhashchange
(browser support).