var imageList = new Array()
imageList.push("1.jpg")
imageList.push("2.jpg")
var obj = document.getElementById("imagecontain")
obj.src = imageList[nIndex%imageList.length]
}
<div><img id="imagecontain" src="1.jpg" /></div>
<script>
var nIndex = 1
objTimer = window.setInterval(function(){
changeSrc(nIndex)
nIndex++
},1000)
document.getElementById("imagecontain").onmousemove = function(){
clearInterval(objTimer)
}
document.getElementById("imagecontain").onmouseout = function(){
objTimer = window.setInterval(function(){
changeSrc(nIndex)
nIndex++
},1000)
}
</script>
</body>
<html><head>
<script language="javascript">
function asd(count,url){
document.getElementById("div1").style.display = "block"
var sp = document.getElementById('sp')
sp.innerHTML = count
if(--count > 0)
setTimeout("asd("+count+",'"+url+"')", 1000)
else
location.href = url
}
</script>
</head>
<body>
<input type="button" onclick="asd(5,'http://www.baidu.com/')" value="点击跳转" />
<div id="div1" style="display:none"><span id="sp"></span>秒后跳转</div>
</body>
</html>
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)