Google Chrome页面在OSX上重新加载 [英] Google Chrome page reloading on OSX

查看:92
本文介绍了Google Chrome页面在OSX上重新加载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



在我的JavaScript中,我在页面加载时将scrollTo滚动到特定部分。



代码很简单:

  $('body')。animate({scrollTop:$ ('nav ul')。position()。top},1000); 

但问题在于,当它滚动页面Google Chrome重新加载页面并且JavaScript未触发再次。

也许有人经历过之前的解决方案或想法,为什么会发生这种情况?



谢谢!



PS忘了举一个实例(不要当做广告) - csspandemic.com



PPS正如人们所说,它在Windows上工作正常,只发生在OSX上。 (我改变了标题。)

解决方案

看起来这是Chrome中的一个错误: http://crbug.com/61674 。 Chrome不会重新加载页面 - 它会将滚动位置恢复到上次加载页面的位置。如果您滚动到页面中的不同位置然后刷新,您将看到跳到最后一个位置;相反,如果你在隐身模式下加载页面,它可以正常工作,因为没有任何缓存的滚动位置。



不幸的是,我不知道一个好解决这个问题。我尝试更改location.hash以尝试使缓存滚动位置失效,但无济于事。


I am experiencing very strange Google Chrome behavior.

In my JavaScript I have scrollTo on page load that scrolls to particular part.

The code is simple as:

$('body').animate({ scrollTop: $('nav ul').position().top }, 1000);

But the problem is that when it scroll the page Google Chrome reload the page and that JavaScript is not firing again.

Maybe some one experiencing that before and have a solution or an idea why that is happening?

Thank you!

P.S. forgot to give an live example (do not take as advertising) - csspandemic.com

P.P.S. As people suggested it is working fine on Windows and happening only on OSX. (I changed the title.)

解决方案

Looks like it's a bug in Chrome: http://crbug.com/61674. Chrome isn't reloading the page -- it's restoring the scroll position to where it was the last time the page was loaded. If you scroll to a different position in the page and then refresh, you will see that the jump is to that last position; conversely, if you load the page in incognito mode, it works fine, because there isn't any cached scroll position.

Unfortunately, I'm not aware of a good workaround for this. I tried changing location.hash in an attempt to invalidate the cached scroll position, but to no avail.

这篇关于Google Chrome页面在OSX上重新加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆