日期:2014-05-16  浏览次数:20363 次

JavaScript切换图片在FireFox中为何无效果??
用一段JAVASCRIPT来切换图片,图片切换的时候有随机的渐变特效
这段代码在IE中显示正常,但在FireFox中图片虽然也可以切换,但却没有了渐变效果,不知为何?

高手解答。


HTML code

<table width="535" height="215" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="450" height="215">

<script language="JavaScript"> //js代码               
    var bannerAD = new Array(); //用于存放图片路径(相对路径)
    var adNum = 0;        
    bannerAD[0] = "image/home1.jpg";
    bannerAD[1] = "image/home2.jpg";
    bannerAD[2] = "image/home3.jpg";
  

function setTransition() {
    if (document.all) {
        bannerADrotator.filters.revealTrans.Transition = Math.floor(Math.random()*23);//设置图片切换
        bannerADrotator.filters.revealTrans.apply(); //应用图片切换
    }
}            

function playTransition(){
    if (document.all)
        bannerADrotator.filters.revealTrans.play() //播放图片
}            

function nextAd(){
    if (adNum < bannerAD.length - 1) 
        adNum++;
    else 
        adNum = 0;
    setTransition();
    document.images.bannerADrotator.src = bannerAD[adNum];
    playTransition();
    theTimer = setTimeout("nextAd()", 5000); //5秒钟切换一张图片
}                          
</script>                            

<img style="FILTER: revealTrans(duration=2,transition=20)" height=292 src="" width=515 border=1 name=bannerADrotator>
<SCRIPT language="JavaScript">nextAd()</SCRIPT>

</td>
</tr>
</table>
 





------解决方案--------------------
if (document.all) {
bannerADrotator.filters.revealTrans.Transition = Math.floor(Math.random()*23);//设置图片切换
bannerADrotator.filters.revealTrans.apply(); //应用图片切换
}
你只写了在IE里的效果(document.all只支持IE)。。又没有写FF里的效果。。当然不显示了。。
------解决方案--------------------
filter滤镜貌似火狐不支持吧
------解决方案--------------------
filters
 滤镜 IE only
------解决方案--------------------
Filter是微软的专有技术,只有IE才支持