我们正在使用 jscrollpane单击散列 anchor (#
) 时在某些 div 中导航。在 Chrome 中单击后退按钮时,地址栏中的 url 会发生变化,但浏览器不会导航回 div。在 Firefox 中,它确实返回到之前的 div。
http://www.sandbox.brightboxstudios.com/swings/test4.html
我已经尝试过各种各样的东西,包括插件、不同的 jquery 库版本。
此外,当 url anchor 不起作用时,我尝试使事件菜单项将类更改为事件状态,这很可能是因为我缺乏 javascript 知识。这也太棒了!
最佳答案
我在你的代码上尝试了这个代码修复:
$('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;
});
导航开始工作。亲自尝试。
关于javascript - 后退按钮在 chrome 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6093265/