scrollTop在Chrome中不起作用,也没有建议的解决方法 [英] scrollTop does not work in Chrome, nor do suggested workarounds

查看:265
本文介绍了scrollTop在Chrome中不起作用,也没有建议的解决方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

许多其他问题(此处这里在哪里)指出 scrollTop似乎不起作用某些版本的Chrome

Numerous other questions (here, here and here) have pointed out that scrollTop appears not to work in some versions of Chrome.

还有一个开放的Chrome问题这里

There is also an open Chrome issue here.

提到了一些变通方法,但没有一项对我有用,我在Ubuntu上使用Chrome 9.0.597.107。

Some workarounds are mentioned but none work for me, I'm using Chrome 9.0.597.107 on Ubuntu.

我需要能够在文档首次加载时读取scrollTop,然后设置它(在顶部元素即body / html / document)。

I need to be able to read scrollTop when the document first loads, and subsequently set it (on the top element i.e. body/html/document).

目前,在Chrome中,scrollTop始终读为0,设置它不会导致文档滚动。

At the moment, in Chrome, scrollTop always reads 0, and setting it does not cause the document to scroll.

是否有人使用原生JS或JQuery找到了解决方案或解决方法

重要的是我无法控制源HTML,我的JS被动态地包含在其中,因此没有任何解决方案可以涉及更改源HTML。

Importantly I do not have control over the source HTML, my JS is being included in it dynamically, so no solution can involve changing the source HTML.

推荐答案

也许你可以使用 window.scroll(x,y);

这篇关于scrollTop在Chrome中不起作用,也没有建议的解决方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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