The following will fire an alert when the page is refreshed if the hash tag ends in twoB:
if (window.location.href.match(/\#twoB/))
{
alert('twoB');
}
The issue is that if you've clicked on a few hash tags and then click back in your browser, although the URL includes the hash the alert doesn't fire. How can I make the code fires (ideally only) after a user has gone back or forward with their browser.
I'm using jQuery for this project so i would like a jQuery solution in an ideal world if the syntax is easier.