JS控件图片移动,无非常是setInterval,setTimeout来控件图片的位置,
示例代码:
<img src="a.jpg" style="position:absolutetop:0pxleft:40%" id="movpic">
<script>
var obj = document.getElementById("movpic")
var tops=0
function movs1()
{tops+=5<br/>obj.style.top = tops<br/>}
setInterval('movs1()',500)
</script>
JS文件:
function show(){var imgid=document.getElementById("imgid")
if(imgid.style.visibility == "visible")
imgid.style.visibility = "hidden"
else
imgid.style.visibility = "visible"
setTimeout('show()',300)
}
HTML:
<img id="imgid" style="visibility:visible" src="1.jpg" />
<button onclick="show()">按下图片会闪动</button>
不知道你是不是这个意思 发现有点没读懂你想要的东西
<SCRIPT language="JavaScript">var speed=50//设置滚动速度
demo2.innerHTML=demo1.innerHTML //复制dome1为dome2
function Marquee(){
if(demo2.offsetTop-demo.scrollTop<=0) //当滚动至dome1与dome2交界时
demo.scrollTop-=demo1.offsetHeight //dome跳到最顶端
else{
demo.scrollTop++
}
}
var MyMar=setInterval(Marquee,speed) //设置定时器
demo.onmouseover=function() {clearInterval(MyMar)}//鼠标移上时清除定时器达到滚动停止的目的
demo.onmouseout=function() {MyMar=setInterval(Marquee,speed)}//鼠标移开时重设定时器,继续滚动
</SCRIPT>
<div id="demo" style="overflow: hiddenheight: 600width: 180background: #214984color: #ffffff">
<div id="demo1" align="center">
<!-- 定义图片 -->
</div>
<div id="demo2" align="center"></div>
</div>