I'm hoping to find a way to get the current viewable window's position (relative to the total page width/height) so I can use it to force a scroll from one section to another.(我希望找到一种方法来获取当前可视窗口的位置(相对于总页面宽度/高度),这样我就可以使用它来强制从一个部分滚动到另一个部分。)
However, there seems to be a tremendous amount of options when it comes to guessing which object holds the true X/Y for your browser.(但是,当猜测哪个对象拥有您浏览器的真实X / Y时,似乎有大量选项。)
Which of these do I need to make sure IE 6+, FF 2+, and Chrome/Safari work?(我需要确保IE 6 +,FF 2+和Chrome / Safari的哪些工作?)
window.innerWidth
window.innerHeight
window.pageXOffset
window.pageYOffset
document.documentElement.clientWidth
document.documentElement.clientHeight
document.documentElement.scrollLeft
document.documentElement.scrollTop
document.body.clientWidth
document.body.clientHeight
document.body.scrollLeft
document.body.scrollTop
And are there any others?(还有其他人吗?) Once I know where the window is I can set an event chain that will slowly call window.scrollBy(x,y);
(一旦我知道窗口在哪里,我就可以设置一个慢慢调用window.scrollBy(x,y);
的事件链window.scrollBy(x,y);
) until it reaches my desired point.(直到达到我想要的程度。)
ask by Xeoncross translate from so
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…