Java Script Scroll Top在Chrome浏览器中不起作用 [英] Java Script Scroll Top is not working in Chrome Browser
本文介绍了Java Script Scroll Top在Chrome浏览器中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用document.documentElement.scrollTop = 200;设置垂直滚动条值。它在Firefox和IE中运行良好,但它不适用于Google Chorme。
如何在Google Chrome中设置此值?在此先感谢。
I am setting vertical scrollbar value using "document.documentElement.scrollTop=200;". It is working fine in Firefox and IE but it is not working in Google Chorme.
How to set this value in Google Chrome? Thanks in advance.
推荐答案
scrollTop
属性不是W3C
标准 - 即使它在大多数浏览器中实现(最初形式为IE
),但不包含在Chrome
中。
名为pageYOffset
的标准属性(IE< 9
不支持) - 尝试一下!
ThescrollTop
property isn'tW3C
standard - even it implemented in most browsers (originally formIE
), but not inChrome
.
The standard property calledpageYOffset
(not supported inIE < 9
) - try it!
window.onload = SetTop;
function SetTop() {
var verticalTop = document.getElementById('<%=hScrollPosition.ClientID %>').value
document.documentElement.pageYOffset = verticalTop;
}
参考 - 跨浏览器JavaScript(不是jQuery ...)滚动到顶部动画 [ ^ ]和试试这项技术。
你也可以点击小提琴 [ ^ ]链接给出了回答以检查演示。
Refer - Cross browser JavaScript (not jQuery…) scroll to top animation[^] and try the technique.
You can also click on the fiddle[^] link given in answer to check the demo.
这篇关于Java Script Scroll Top在Chrome浏览器中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文