Javascript图像动画在Firefox或Internet Explorer中不起作用
Javascript Image Animation does not work in Firefox or Internet Explorer
我正在使用以下脚本生成图像动画。
它适用于Chrome,但不适用于Firefox或Internet Explorer。。。
Javascript
var lista = new Array('image1.gif','image1.gif','image1.gif','image1.gif');
var tiempo = 500;
var tempor = null;
var pos=0;
var i = 0;
function boucle_images(){
var nombre_total_images = 6;
document.images.centro.src = lista[i]
pos=i;
i++;
i%=nombre_total_images;
tempor=setTimeout("boucle_images()",tiempo);
}
function avanza(){
if (pos==(lista.length-1))
pos=0;
else
pos++;
document.images.centro.src = lista[pos]
}
function retroceso(){
if (pos==0)
pos=(lista.length-1);
else
pos--;
document.images.centro.src = lista[pos]
}
function automat(){
tempor = setTimeout("boucle_images()", tiempo)
}
function parar(){
clearTimeout(tempor);
}
HTML
<table width="52%" border="0" align="center">
<tr>
<td height="482" colspan="2" align="right">
<img id="centro" src="imagenes/cargando2.gif" alt="" width="640" height="480" /></td>
</tr>
<tr>
<td align="center"><div class="div_ani_sat">
<a href="javascript:retroceso()"><img src="imagenes/atras.png" width="48" height="48" alt="" /></a>
<a href="javascript:avanza()"><img src="imagenes/adelante.png" width="48" height="48" alt="" /></a>
<a href="javascript:boucle_images()"><img src="imagenes/play.png" width="48" height="48" alt="" /></a>
<a href="javascript:parar()"><img src="imagenes/pause.png" width="48" height="48" alt="" /></a></div>
</td>
</tr>
</table>
并不是说我不能在其他浏览器中工作。。。你能帮忙吗?感谢
这是在chrome+firefox中测试的同一代码的工作版本
setTimeout接受第一个参数作为对函数的引用。所以,我只是把你的tempor=setTimeout("boucle_images()",tiempo)
换成了tempor=setTimeout(boucle_images, tiempo)
。总是遵循这个,因为它节省了一个评估
document.images
返回一个HTML Collection
,您可以像数组一样访问它[但它不是数组],但不像document.image.centros
[至少在浏览器之间]。因此,我将其修复为document.getElementById('centros')
相关文章:
- 视频HTML没有'无法在Internet Explorer 11上工作
- Internet Explorer缺少占位符支持,特别是密码字段
- Internet Explorer中的文本换行错误
- 为什么我在Internet Explorer上看不到html元素
- internet explorer 8兼容模式下的Youtube api错误
- 当浏览器控制台未打开时,为什么要求会导致Internet Explorer 9超时
- Internet Explorer 8. Events
- jQuery表单验证适用于Mozilla和Internet Explorer,但不适用于Chrome或Safari
- element.dataset in Internet Explorer
- Facebook FB.init”;访问被拒绝”;在Internet Explorer 11中
- JavaScript不适用于internet explorer和Firefox,但适用于谷歌
- 在Internet Explorer中,向所选内容添加选项不起作用
- 在Internet Explorer中从二进制文件打开PDF
- elementproblem internet explorer
- 我可以使用哪些方法在Internet Explorer中禁用Alt+*X*
- 如何在Internet Explorer中使用javascript设置cookie
- 只有当alert()在带有AJAX的internet explorer中使用时,Javascript才会更新UI
- sharepoint站点的internet explorer中出现Javascript错误
- Internet Explorer重新加载IFrame
- 如何在不使用Internet Explorer的情况下从未挂起的HTML文件执行程序