自动切换的广告图片

来源:互联网 发布:mac系统flash插件 编辑:程序博客网 时间:2024/04/30 22:08
<!DOCTYPE html><html lang="zh-cn"><head>    <meta charset="UTF-8">    <title>Document</title></head><body>    <img src="images/1.png" alt="" id="imgid"><script>   // 自动切换的广告图片    window.onload=rotate;    var Adimg=["images/1.png","images/2.png","images/3.png"];    var adimg=0;    function rotate(){        adimg++;        if(adimg==Adimg.length){            adimg=0;        }        document.getElementById('imgid').src=Adimg[adimg];        setTimeout(rotate,3000);    }     //显示随机图片    /*    window.onload=rotate;    function rotate(){        var Adimg=["images/1.png","images/2.png","images/3.png"];        var a=Math.floor((Math.random()*Adimg.length));        document.getElementById('imgid').src=Adimg[a];    }    */    //单击图片切换    /*    var imgid=document.images['imgid'];    var ab=true;    imgid.onclick=function(){        if(ab){        imgid.src='images/2.png';        ab=false;    }else{        imgid.src='images/1.png';        ab=true;    }    }    */</script></body></html>
0 0