I'm trying to load different content with JavaScript on a page, depending on its hash tag. However, it should also work in older browsers which do not support the popstate method.
The problem is, that when looking at window.location.hash
after I click on a link (e.g. #newhashtag
) on the current page (e.g. example.com/#currenthashtag
), on document.ready
it still shows me the old hash tag. Only after clicking on a second link, the previous hash tag from the first link shows up in window.location.hash
.
So, what is the easiest way to handle different hash states of a website without using popstate?