我现在真的在 JS 中挣扎。我今天花了几个小时来进出更改代码,但我无法让它工作:我知道数组或循环可能会更好,但我现在什至无法让基本代码工作。谢谢 :)
“使用五个图像;创建一个循环显示图像的脚本,使用 setInterval 将每个图像显示 5 秒钟。”
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http-//www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="">
<head>
<title>Concerts</title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<script type="text/javascript">
/* <![CDATA[ */
var curImage = "concert5";
function bannerAd() {
if (curImage == "concert1") {
document.images[0].src= "images/concert2.gif";
curImage = "concert2.gif";
{
if (curImage == "concert2") {
document.images[0].src= "images/concert3.gif";
curImage = "concert3";
}
if (curImage == "concert3") {
document.images[0].src= "images/concert4.gif";
curImage = "concert4";
}
if (curImage == "concert4") {
document.images[0].src= "images/concert5.gif";
curImage = "concert5";
}
if (curImage == "concert5") {
document.images[0].src= "images/concert1.gif";
curImage = "concert1";
}
}
/* ]]> */
</script>
</head>
<body onload= "curImage = setInterval('bannerAd()',5000);">
<img src = ??? width="462" height="87" alt="Concert ads"/>
</body>
</html>