在后退按钮上,为什么 Firefox 直接跳到我之前的滚动位置而不是动画
请访问演示:http://96.0.13.132
点击一会儿,然后点击后退按钮。在 webkit 浏览器中,你会被动画回到之前的“状态”,而在 Firefox 中你会跳回来。这是为什么呢?如何让 Firefox 表现得更像 webkit?
我正在使用 jQuery、jQuery Address 插件和 jQuery ScrollTo 插件。
Please visit the demo: http://96.0.13.132
Click around for awhile, now hit the back button. In webkit browsers, you are animated back to the previous "state" while in Firefox you jump back. Why is this? How can I get Firefox to behave more like webkit?
I'm using jQuery, jQuery Address Plugin and jQuery ScrollTo Plugin.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
缺少拦截后退按钮然后应用您的效果想要用 jQuery 实现,这很可能是 Firefox、Opera(在 Windows XP 上的 v11.60 中测试)的“设计”,并且..无法在 Internet Explorer 8 中测试它,因为
这会使浏览器进入白屏。它几乎加载了页面,然后立即完全破坏了网站。您可以通过使用封装任何
console
命令来解决这个问题,这是一个很好的做法,因为您应该善待没有控制台或FireBug的浏览器™...但随后您还会收到一个非常唐突的
警报
,告诉访问者所以我想说的是,在返回主要的视觉问题之前,您应该首先更多地关注网站可用性的这些方面。除非您 100% 确定只有 Safari 用户会访问您的网站,否则您确实不应该在访问者第一次访问您的网站时向他们显示弹出窗口或错误,从而让他们感到不受欢迎。
Short of intercepting the back button and then applying the effect you want to achieve with jQuery, this is quite likely "by design" for Firefox, Opera (tested in v11.60 on Windows XP) and .. couldn't test it in Internet Explorer 8 because
which made the browser go to a white screen. It pretty much loaded the page and then immediately broke the site completely. You can fix that by using encapsulating any
console
commands withwhich is just good practice because you should Be Nice To Browsers That Don't Have a Console Or FireBug™...but then you've also got a very obtrusive
alert
that tells a visitorSo what I'm building up to saying is that you should focus a little more on just those aspects of the usability of your site first before returning to mostly visual concerns. Unless you're 100% certain that only Safari users will visit your site, you really shouldn't make your visitors feel unwelcome by presenting them with a pop-up or error on their first entry to your site.
我认为问题在于我滚动到 id 与哈希值匹配的页面,并且默认跳转到 id 行为覆盖了绑定到后退按钮的动画。
例如,我的链接是“#about”,并且我有一个 id 为“about”的元素,因此 Firefox 在我可以为滚动设置动画之前直接滚动到它。将元素的 id 更改为“page_about”似乎可以解决该问题。
您可以在此处查看制作站点:http://www.erny.com
I believe the problem was that I was scrolling to pages with an id that matched the hash and the default jump to id behavior was overriding my animations that were bound to the back button.
For example, my link would be to "#about" and I had an element with an id of "about", so Firefox scrolled straight to it before I could animate a scroll to it. Changing the id of the element to "page_about" seemed to fix the problem.
You can see the production site here: http://www.erny.com