简体   繁体   English

恢复内置的javascript函数

[英]Restore built in javascript functions

Is this possible? 这可能吗?

Very much in need of the window.scrollTo() function, but it seems that sites like Facebook and others have removed them (or at least removed the references). 非常需要window.scrollTo()函数,但似乎Facebook之类的网站已将其删除(或至少删除了引用)。

They have not removed them. 他们尚未删除它们。 It does matter when you call them though. 不过,当您致电给他们时,这确实很重要。

Since most content if FB is brought in the page by ajax, if you call the scroll before the content is fetched, there is nowhere to scroll.. 由于大多数内容(如果FB是由ajax带来的),如果在获取内容之前调用滚动,则无处滚动。

If you open firebug ( or whatever javascript console you use ) and issue a window.scrollTo(0,1000) while a page is displayed, it will scroll just fine. 如果打开Firebug( 或使用的任何 Java 控制台 )并在显示页面时发出window.scrollTo(0,1000),它将滚动得很好。 So it is there. 在那里。

So be more specific about what you are trying to do, so we can see if we can help. 因此,请更加具体地说明您要做什么,以便我们可以提供帮助。


update after comment 评论后更新

For orkut specifically: They have created a wrapper div of the whole content that is 100% width and height. 专门针对orkut:他们创建了一个内容为100%宽度和高度的包装div So the window does not have any room to scroll, as all content is isnide the wrapped and the scroll happens there. 因此,窗口没有任何滚动空间,因为所有内容都被包装,并且滚动在那里发生。 So the window.scrollTo does nothing ( it exists though ). 因此, window.scrollTo不执行任何操作( 尽管存在 )。

To actually scroll in there you need to find the container div which is the parent of the one with id gwtPanel and use its scrollTop property. 要在其中实际滚动,您需要找到容器div ,该容器是ID为gwtPanel的容器的父级,并使用其scrollTop属性。

var scrollingNode = document.getElementById('gwtPanel').parentNode;
scrollingNode.scrollTop=500;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM