Google Chrome page reloading on OSX

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-24 10:49:30

问题


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.)


回答1:


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.



来源:https://stackoverflow.com/questions/13600832/google-chrome-page-reloading-on-osx

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!