我正在尝试使用Javascript循环几个横幅图像 以下是我试过的代码。有谁知道为什么我不能让这个工作?
<!DOCTYPE html PUBLIC"-//W3C//DTD XHTML 1.0 --->Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Contact Page</title>
<script language="Javascript" type="text/javascript">
<!--- Hide Script from Old Browsers
adImages1 = new Array("http://www.rmar.in/images/service/web3.png","http://www.rmar.in/images/service/web3.png","http://www.rmar.in/images/service/web3.png")
adImages2 = new Array("http://www.triadsearchmarketing.com/wp-content/uploads/2015/06/web-design-banner.jpg","http://www.triadsearchmarketing.com/wp-content/uploads/2015/06/web-design-banner.jpg")
thisAd1 = 0
thisAd2 = 0
imgCt1 = adImages1.length
imgCt2 = adImages2.length
function rotate() {
if (document.images) {
thisAd1++
if (thisAd1 == imgCt1) {
thisAd1 = 0
}
document.adBanner1.src=adImages1 [thisAd1]
thisAd2++
if (thisAd2 == imgCt2) {
thisAd2 = 0
}
document.adBanner2.src=adImages2
[thisAd2]
setTimeout("rotate()", 3 * 1000)
}
}
// End hiding script from old browsers -->
</script>script>
</head>
<body bgcolor="#FFFFFF" onload="rotate()">
<center>
<img src="http://www.triadsearchmarketing.com/wp-content/uploads/2015/06/web-design-banner.jpg" width ="400" height="75" name="adBanner1" vspace="10" alt="Ad Banner 1" /> <br/>
<img src="http://www.rmar.in/images/service/web3.png" width ="400" height="75" name="adBanner1" vspace="10" alt="Ad Banner 1" />
</center>
</body>
<html>
&#13;
答案 0 :(得分:0)
您正在重复使用dataF
名称。在下面的代码中我是:
adBanner1
adBanner2
&#13;