看起来你们是我的帮助javascript。当我加载我的网页的本地副本时,我有一个完美的幻灯片。但是,当我加载托管在GoDaddy上的实际页面时,它不起作用。第一张图片显示,但只是静态的。控制台显示没有错误。再一次,非常感谢任何和所有帮助。
<div class="auto-style1" style="width: 226px; height: 179px">
<script language="javascript" type="text/javascript">
var i = 0; var path = new Array();
// LIST OF IMAGES
path[0] = "images/image_1.png";
path[1] = "images/image_2.png";
path[2] = "images/image_3.png";
path[3] = "images/image_4.png";
path[4] = "images/image_5.png";
path[5] = "images/image_6.png";
function swapImage()
{
document.slide.src = path[i];
if(i < path.length - 1) i++;
else i = 0;
setTimeout("swapImage()",3000);
}
window.onload=swapImage;
</script>
<img alt="" name="slide" height="140" src="images/image_1.png" width="224" class="auto-style2" />
</div>
答案 0 :(得分:0)
您需要在文件夹名称前加上&#34; /&#34; 。
将路径设为
path[0] = "/images/image_1.png";
path[1] = "/images/image_2.png";
path[2] = "/images/image_3.png";
path[3] = "/images/image_4.png";
path[4] = "/images/image_5.png";
path[5] = "/images/image_6.png";
答案 1 :(得分:0)
2件事。
答案 2 :(得分:0)
我无法让您的代码正常运行。试试这个:
var i = 0; var path = new Array();
// LIST OF IMAGES
path[0] = "images/image_1.png";
path[1] = "images/image_2.png";
path[2] = "images/image_3.png";
path[3] = "images/image_4.png";
path[4] = "images/image_5.png";
path[5] = "images/image_6.png";
function swapImage()
{
var img = document.getElementById("slide");
img.src = path[i];
i++;
if(i >= path.length){
i = 0;
}
setTimeout(function() { swapImage() }, 3000);
}
window.onload=swapImage();