We are using jscrollpane to navigate through some divs when clicking a hash anchor (#
). When the back button is clicked in Chrome, the url changes in the address bar but the browser does not navigate back to the div. In Firefox it does go back to the previous div.
http://www.sandbox.brightboxstudios.com/swings/test4.html
I have tried all kinds of things including plug-ins, different jquery library versions.
Also, everything I have tried to make the active menu items change class to active when on the url anchor hasn't worked, most likely because of my lack of javascript knowledge. This would be awesome to fix as well!
I tried this code fix over your code:
$('ul.nav a')
.unbind("click") // to remove your binding in my console
.bind('click',function(event){ // rebind event handler
var $anchor = $(this);
$('html, body').stop().animate({
scrollLeft: $($anchor.attr('href')).offset().left
}, 1500,'easeInOutExpo');
event.preventDefault();
// this is a trick:
location.href = $anchor.attr('href');
return false;
});
and navigation started working. Try it yourself.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With