Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Back button not working in chrome

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!

like image 785
Reuben Avatar asked Nov 14 '22 22:11

Reuben


1 Answers

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.

like image 112
Genius Avatar answered Nov 16 '22 19:11

Genius