出于某种原因,它会显示第一张图片,但不会滑到下一张图片上。图像源应该没问题,但是一旦我在我的图像的php标签中添加了滑块功能停止
头标记中的脚本:
var slideimages = new Array() // create new array to preload images
slideimages[0] = new Image() // create new instance of image object
slideimages[0].src = "<?php echo "<img src='images/$firstslider'/>";?>"
slideimages[1] = new Image()
slideimages[1].src = "<?php echo "<img src='images/$secondslider'/>";?>"
slideimages[2] = new Image()
slideimages[2].src = "<?php echo "<img src='images/$thirdslider'/>";?>"
正文中滑块的代码:
<div id="slider">
<a href="#" id="slide" width="910px" height="250px"><?php echo "<img src='images/$firstslider' />";?></a>
<script type="text/javascript">
var step = 0
function slideit() {
if (!document . images)
return
document.getElementById ('slide').src = slideimages[step].src
if (step < 2)
step++
else
step = 0
setTimeout("slideit()", 2500)
}
slideit()
</script>
答案 0 :(得分:0)
您正尝试将图像元素指定给图像源属性
改为使用:
slideimages[0].src = "<?= "images/$firstslider" ?>"