高效的javascript 幻灯片

javascript 幻灯片播放,在网上见到的都挺复杂感觉,自己动手写一个简单的,用时候只需更改图片路径就行了,其它的参数代码里也能改,本代码最大的亮点是简单高效。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>简单高效的javascript 幻灯片播放</title>
</head>
<body>
<div>
<div id="divs">
<img  src="/jscss/demoimg/wall1.jpg" id="1"  style="FILTER: revealTrans(duration=2,transition=16); cursor:pointer;" οnclick="location.href = 'http://www.163.com'">
<img  src="/jscss/demoimg/wall2.jpg" id="2"   style="FILTER: revealTrans(duration=2,transition=17);  cursor:pointer;display:none" οnclick="location.href = 'http://www.sina.com.cn'">
<img  src="/jscss/demoimg/wall3.jpg" id="3"   style="FILTER: revealTrans(duration=2,transition=18);  cursor:pointer;display:none" οnclick="location.href = 'http://www.codefans.net'">
<img  src="/jscss/demoimg/wall4.jpg" id="4"   style="FILTER: revealTrans(duration=2,transition=19);  cursor:pointer;display:none" οnclick="location.href = 'http://www.qq.com'">
<img  src="/jscss/demoimg/wall5.jpg" id="5"   style="FILTER: revealTrans(duration=2,transition=20);  cursor:pointer;display:none" οnclick="location.href = 'http://www.google.com'">
<img  src="/jscss/demoimg/wall6.jpg" id="6"   style="FILTER: revealTrans(duration=2,transition=21);  cursor:pointer;display:none" οnclick="location.href = 'http://www.baidu.com'">
</div>
<script language="javascript">
function $(_sId) {
    return document.getElementById(_sId);
}
var speed=3000;
var setid=null;
var auto="true";
function galleryplay(divs,a,mtime){ //t为要应用此函数的id,a初始化时显示的项目的顺序数
    if(divs=="0")return false;   
    var start=3;
    if(auto=="true")
    {
        start = a-1;//初始项目
        speed = mtime;//切换间隔
        setid = null;//定时器    
        var loop = function(){ //自动切换        
            ids = divs.split(",");                       
            for (var i=0;i<ids.length; i++)
            {           
                 $(ids[i]).style.display='none';
           
            }                                   
            $(ids[start]).filters.revealTrans.Transition = Math.floor(Math.random() * 23);
            $(ids[start]).filters.revealTrans.apply();
            $(ids[start]).filters.revealTrans.play();
            $(ids[start]).style.display='';
           
            setid=setTimeout(loop,speed);
            start++;
            if(start==ids.length){
                start=0;                 
            }
        };loop();    
    }
}
galleryplay('1,2,3,4,5,6',1,3000);
</script>
</div>
</body>
</html>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值