首页 > 网站 > WEB开发 > 正文

图片定时自动播放

2024-04-27 14:17:31
字体:
来源:转载
供稿:网友

图片定时自动播放

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>图片定时自动播放</title> <script type="text/javascript"> var banner = ["images/banner.jpg","images/banner1.jpg","images/banner2.jpg"];var number = 0;function sun() {setInterval(cycle,2000);}function cycle() {number++;if(number == banner.length) number = 0;document.getElementById("banner").src = banner[number];} </script></head>

<body onload="sun();"><img id="banner" src="images/banner.jpg" /></body></html>


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表