如何让 Iframe 像电影演职员表一样向下滚动
How do I get an Iframe to scroll down like movie credits?
我有一个Iframe,它循环浏览一系列已发布的Google表格。 有没有办法让 iframe 随着时间的推移向下滚动以显示已发布 URL 中的所有数据?
理想情况下,我想让结果表从顶部开始,超过 30 秒,向下滚动到底部,然后在底部时切换到下一个结果表。 然后,这将不断从站点 1 循环到站点 5。
这是我的代码:
var sites = [
"https://docs.google.com/spreadsheets/d/1Gd4eYAukSIvU0VS_zt37TWNiKi15-lB3V8f5AA3IXJU/pubhtml?gid=0&single=true",
"https://docs.google.com/spreadsheets/d/1Gd4eYAukSIvU0VS_zt37TWNiKi15-lB3V8f5AA3IXJU/pubhtml?gid=1991236368&single=true",
"https://docs.google.com/spreadsheets/d/1Gd4eYAukSIvU0VS_zt37TWNiKi15-lB3V8f5AA3IXJU/pubhtml?gid=205619546&single=true",
"https://docs.google.com/spreadsheets/d/1Gd4eYAukSIvU0VS_zt37TWNiKi15-lB3V8f5AA3IXJU/pubhtml?gid=1480439822&single=true",
"https://docs.google.com/spreadsheets/d/1Gd4eYAukSIvU0VS_zt37TWNiKi15-lB3V8f5AA3IXJU/pubhtml?gid=1101347808&single=true"
];
var currentSite = sites.length;
$(document).ready(function() {
var $iframe = $("iframe").attr("src", "https://docs.google.com/spreadsheets/d/1Gd4eYAukSIvU0VS_zt37TWNiKi15-lB3V8f5AA3IXJU/pubhtml?gid=0&single=true");
setInterval(function() {
(currentSite == 1) ? currentSite = sites.length - 1: currentSite = currentSite - 1;
$iframe.attr("src", sites[currentSite]);
}, 10000);
});
iframe {
height: 768px;
width: 1024px;
border: 2px solid gray;
}
body {
width: 1024px;
length: 768px;
background-color: #C9C9C9;
margin: 0 auto;
}
#heading-wrapper {
margin: 0 auto;
background-color: #FF6600;
border: 2px solid black;
text-align: center;
width: 1024px;
}
#heading-wrapper h1 {
font-family: Arial;
vertical-align: middle;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<head>
<title>Live Results</title>
</head>
<body>
<div id="heading-wrapper">
<h1>Live Results</h1>
</div>
<iframe></iframe>
</body>
我什至不知道是否可以让它慢慢向下滚动。
看看
iframe.contentWindow.scrollTo(x, y);
您可以创建一个函数,该函数以递增的 y 滚动量定期调用该函数。
使用设置间隔并更改包含元素的 scrollTop 属性:
setInterval(changeScrollPosition, 50); // every 50 milliseconds
function changeScrollPosition(el)
{
var currentTop = el.scrollTop;
el.scrollTop = currentTop + howMuchYouWantToScrollBy;
}
相关文章:
- 幻灯片滚动javascript不起作用
- 将视口底部滚动到元素底部
- 如何检测滚动事件是否像在触摸设备上一样只触发一次
- 像谷歌一样更改滚动网站
- css 和 JavaScript 像 iOS 照片应用程序一样滚动
- JavaScript html 像在 iOS 中一样滚动
- 如何让 Iframe 像电影演职员表一样向下滚动
- 如何创建像格鲁克网站一样的滚动效果
- 加载更多项目,而无需滚动或按“查看更多”,就像在Facebook中使用JS一样
- jQuery鼠标每次滚动整个窗口,就像aplle iphone5网站一样
- 鼠标悬停时垂直自动滚动 - 就像“项目赠品”deviantart.com 一样
- 如何向下滚动像向上滚动一样,向下滚动我没有得到页面高度
- jqueryui模式窗口,只让其中一部分像新的Facebook照片标签窗口一样滚动
- 像k2.pl一样平滑的水平滚动
- 如何为应用程序截图创建一个漂亮的水平滚动区域,就像iTunes上的应用程序一样
- 禁用滚动覆盖像Facebook一样活跃
- 像change.org一样快速滚动
- 当像facebook一样滚动到底部时加载更多(Jsp或servlet)
- 如何使用客户端浏览器滚动加载HTML内容,就像在facebook主页一样
- 我可以像Chromium smooth Scroller一样在html页面中实现平滑滚动吗