简体   繁体   English

如何每5秒自动向下滚动iframe 100像素?

[英]How to auto scroll down an iframe 100px every 5 secs?

I would like to know how can I scroll down an iframe 100px every 5 secs using maybe javascript. 我想知道如何才能每5秒使用javascript向下滚动iframe 100px。 I know that there is a window.scrollTo(x,y); 我知道有一个window.scrollTo(x,y); but how does this change to an iframe? 但是如何更改为iframe?

The iframe is an external page. iframe是一个外部页面。
Any possibility of software to download that does this thing? 做这个东西的软件是否有可能下载?

This isn't possible if you do not have control of the external page's code. 如果您无法控制外部页面的代码,则无法执行此操作。 browsers prevent this type of thing for security reasons. 浏览器出于安全原因会阻止此类事件。 Its considered cross-domain scripting . 它被认为是跨域脚本

Is there an updated version to this method? 此方法是否有更新版本? Not finding it to actually control the content within the http://time.com"> 找不到它可以实际控制http://time.com“>中的内容

not showing. 没有显示。 Thats rather puzzling. 那真是令人困惑。 So typing iframe inside an iframe makes it go invisible.. 因此,在iframe中键入iframe使其不可见。

You can use setInterval to do the scrolling every 5 seconds. 您可以使用setInterval每5秒滚动一次。 the scrolling itsself can be done with this . 滚动本身可以做到这一点

Its very easy using a jquery, 使用jQuery非常容易,

Lets say the id of your iframe is testframe then the code for it would be 假设您的iframe的ID为testframe则其代码为

$("#testframe").scrollTop(400).scrollLeft(400);

Now just wrap it inside an interval and put it inside. 现在,将其包装在一个间隔内,然后放入其中。

var tick=1;
function scrolldown(tick) {
    $("#testframe").scrollTop(tick*100);
}
self.setInterval("scrolldown("+(tick+1)+")",5000);

Note: Just a typo 注意:只是拼写错误

If you are building a desktop application (Windows, Linux, not quite sure), I would suggest you to find a component that is the java equivalent of the C# web browser control. 如果要构建桌面应用程序(Windows,Linux,不太确定),建议您找到一个与C#Web浏览器控件的Java等效的组件。

Since this control is loaded in a desktop applicaiton, you have full control over the browser loaded document (eg you can manipulate it, without being in a cross domain context). 由于此控件是在桌面应用程序中加载的,因此您可以完全控制浏览器加载的文档(例如,您可以在跨域上下文中对其进行操作)。

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

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