我有一个iframe循环播放已发布的Google表单数组。有没有办法可以让iframe向下滚动以显示已发布网址中的所有数据?
理想情况下,我希望结果表从顶部开始超过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>
&#13;
我甚至不知道是否可以慢慢向下滚动。
答案 0 :(得分:0)
看看
{
"kind": "Status",
"apiVersion": "v1",
"metadata": {},
"status": "Failure",
"message": "the server responded with the status code 415 but did not return more information",
"details": {},
"code": 415
}
您可以创建一个定期调用y滚动量增加的函数。
答案 1 :(得分:0)
使用set interval并更改包含元素的scrollTop属性:
setInterval(changeScrollPosition, 50); // every 50 milliseconds
function changeScrollPosition(el)
{
var currentTop = el.scrollTop;
el.scrollTop = currentTop + howMuchYouWantToScrollBy;
}