<body>
<div id="scr" style="overflow:auto; width: 100%; height: 100%; ">
<p id="content"></p>
</div>
var sites = ['linkexample.com','http://link2.com','http://link3.com'];
i = 3;
ctr = 0;
while(ctr < i){
document.getElementById("content").innerHTML = '<object width="100%" height="100%" data="' + sites[ctr] + '"></object>';
function ScrollDiv(){
if(document.getElementById('scr').scrollTop<(document.getElementById('scr').scrollHeight-document.getElementById('scr').offsetHeight)){-1
document.getElementById('scr').scrollTop=document.getElementById('scr').scrollTop+1
}
else {
ctr++;
}
setInterval(ScrollDiv,5) }
};
答案 0 :(得分:0)
此代码示例遍历数组并将网址加载到<p id="content"></p>
此外,我已更正了您的代码中的一些错误。
<!DOCTYPE html>
<html>
<head>
<title></title>
<style type="text/css">
</style>
</head>
<body>
<div id="scr" style="overflow:auto; width: 100%; height: 100%; ">
<p id="content"></p>
</div>
</body>
<script type="text/javascript">
var ctr = 0;
var sites = ['http://link1.com', 'http://link2.com', 'http://link3.com'];
function ScrollDiv(){
if(document.getElementById('scr').scrollTop<(document.getElementById('scr').scrollHeight-document.getElementById('scr').offsetHeight)){
document.getElementById('scr').scrollTop=document.getElementById('scr').scrollTop+1;
}else{
ctr++;
if(ctr>2){
ctr=0;
}
document.getElementById("content").innerHTML = '<object width="100%" height="100%" data="' + sites[ctr] + '"></object>';
}
}
setInterval(ScrollDiv, 3000);
</script>
</html>
您提供的示例中没有页面内容。我不清楚你想用卷轴做什么。