0

I have used the following code to change the url hash as I click through my slider, however I am now wondering if it is possible that when a user changes the slide number themselves in the url, the slide will change according to the entered hash, sort of the reverse of what i have already, any help is very appreciated thanks.

var hash = $(".active").data("id");
location.hash = hash;
user1688604
  • 103
  • 1
  • 2
  • 9

1 Answers1

1

What you're looking for is the onhashchange-event.

It's not supported in all browsers versions, but you could use a polyfill (there are plenty available for jQuery), or you could do a simple feature detection like this

if ("onhashchange" in window) {
    $(window).bind( 'hashchange', function(e) { })
}
Simon Kjellberg
  • 826
  • 8
  • 17