0
我有一个脚本运行在我的网页上来更改图像。我想在同一页面的其他地方重复使用6次,但当我重复使用时,它不会起作用。问题与Javascript图像转换器
var delay = 2000 //set delay in miliseconds
var curindex = 0
var randomimages = new Array()
randomimages[0] = "hhh200.jpg"
randomimages[1] = "ray200.jpg"
var preload = new Array()
for (n = 0; n < randomimages.length; n++) {
preload[n] = new Image()
preload[n].src = randomimages[n]
}
document.write('<img name="defaultimage" src="' + randomimages[Math.floor(Math.random() * (randomimages.length))] + '">')
function rotateimage() {
if (curindex == (tempindex = Math.floor(Math.random() * (randomimages.length)))) {
curindex = curindex == 0 ? 1 : curindex - 1
} else curindex = tempindex
document.images.defaultimage.src = randomimages[curindex]
}
setInterval("rotateimage()", delay)
任何人都可以看到为什么它不工作?
需要比“但它不会工作”,以帮助更多的细节。 –
你的代码正在使用我的FF 7.0.1 – user973254
是的,我知道它的作品,但是当我复制并粘贴到页面上的其他地方时,所有图像都不会改变?他们都留在文具 –