本文实例讲述了JS实现的多张图片轮流播放幻灯片效果。分享给大家供大家参考,具体如下:
<body style="width: 715px; height: 95px;"> <script language="javascript" type="text/javascript"> <!-- /************************************************** 名称: 图片轮播类 创建时间: 2010-07-11 zhangty 示例: 页面中已经存在名为imgPlayer(或者别的ID也行)的节点. PImgPlayer.addItem( "test", "http://www.pomoho.com", "http://static.pomoho.com/static/samesong/images/logo5.jpg"); PImgPlayer.addItem( "test2", "http://www.pomoho.com.cn", "http://static.pomoho.com/static/samesong/images/logo4.jpg"); PImgPlayer.addItem( "test3", "http://www.pomoho.com.cn", "http://static.pomoho.com/static/samesong/images/logo3.jpg"); PImgPlayer.init( "imgPlayer", 200, 230 ); 备注: 适用于一个页面只有一个图片轮播的地方. ***************************************************/ var PImgPlayer = { _timer : null, _items : [], _container : null, _index : 0, _imgs : [], intervalTime : 5000, //轮播间隔时间 init : function( objID, w, h, time ){ this.intervalTime = time || this.intervalTime; this._container = document.getElementById( objID ); this._container.style.display = "block"; this._container.style.width = w + "px"; this._container.style.height = h + "px"; this._container.style.position = "relative"; this._container.style.overflow = "hidden"; //this._container.style.border = "1px solid #fff"; var linkStyle = "display: block; TEXT-DECORATION: none;"; if( document.all ){ linkStyle += "FILTER:"; linkStyle += "progid:DXImageTransform.Microsoft.Barn(duration=0.5, motion='out', orientation='vertical') "; linkStyle += "progid:DXImageTransform.Microsoft.Barn ( duration=0.5,motion='out',orientation='horizontal') "; linkStyle += "progid:DXImageTransform.Microsoft.Blinds ( duration=0.5,bands=10,Direction='down' )"; linkStyle += "progid:DXImageTransform.Microsoft.CheckerBoard()"; linkStyle += "progid:DXImageTransform.Microsoft.Fade(duration=0.5,overlap=0)"; linkStyle += "progid:DXImageTransform.Microsoft.GradientWipe ( duration=1,gradientSize=1.0,motion='reverse' )"; linkStyle += "progid:DXImageTransform.Microsoft.Inset ()"; linkStyle += "progid:DXImageTransform.Microsoft.Iris ( duration=1,irisStyle=PLUS,motion=out )"; linkStyle += "progid:DXImageTransform.Microsoft.Iris ( duration=1,irisStyle=PLUS,motion=in )"; linkStyle += "progid:DXImageTransform.Microsoft.Iris ( duration=1,irisStyle=DIAMOND,motion=in )"; linkStyle += "progid:DXImageTransform.Microsoft.Iris ( duration=1,irisStyle=SQUARE,motion=in )"; linkStyle += "progid:DXImageTransform.Microsoft.Iris ( duration=0.5,irisStyle=STAR,motion=in )"; linkStyle += "progid:DXImageTransform.Microsoft.RadialWipe ( duration=0.5,wipeStyle=CLOCK )"; linkStyle += "progid:DXImageTransform.Microsoft.RadialWipe ( duration=0.5,wipeStyle=WEDGE )"; linkStyle += "progid:DXImageTransform.Microsoft.RandomBars ( duration=0.5,orientation=horizontal )"; linkStyle += "progid:DXImageTransform.Microsoft.RandomBars ( duration=0.5,orientation=vertical )"; linkStyle += "progid:DXImageTransform.Microsoft.RandomDissolve ()"; linkStyle += "progid:DXImageTransform.Microsoft.Spiral ( duration=0.5,gridSizeX=16,gridSizeY=16 )"; linkStyle += "progid:DXImageTransform.Microsoft.Stretch ( duration=0.5,stretchStyle=PUSH )"; linkStyle += "progid:DXImageTransform.Microsoft.Strips ( duration=0.5,motion=rightdown )"; linkStyle += "progid:DXImageTransform.Microsoft.Wheel ( duration=0.5,spokes=8 )"; linkStyle += "progid:DXImageTransform.Microsoft.Zigzag ( duration=0.5,gridSizeX=4,gridSizeY=40 ); width: 100%; height: 100%"; } // var ulStyle = "margin:0;width:"+w+"px;position:absolute;z-index:999;right:5px;FILTER:Alpha(Opacity=30,FinishOpacity=90, Style=1);overflow: hidden;bottom:-1px;height:16px; border-right:1px solid #fff;"; // var liStyle = "margin:0;list-style-type: none; margin:0;padding:0; float:right;"; // var baseSpacStyle = "clear:both; display:block; width:23px;line-height:18px; font-size:12px; FONT-FAMILY:'宋体';opacity: 0.6;"; baseSpacStyle += "border:1px solid #fff;border-right:0;border-bottom:0;"; baseSpacStyle += "color:#fff;text-align:center; cursor:pointer; "; // var ulHTML = ""; for(var i = this._items.length -1; i >= 0; i--){ var spanStyle = ""; if( i==this._index ){ spanStyle = baseSpacStyle + "background:#ff0000;"; //初始化底部数字的颜色 } else { spanStyle = baseSpacStyle + "background:#c0c0c0;"; //初始化底部数字的背景颜色 } ulHTML += "<li style=\""+liStyle+"\">"; ulHTML += "<span onmouseover=\"PImgPlayer.mouseOver(this);\" onmouseout=\"PImgPlayer.mouseOut(this);\" style=\""+spanStyle+"\" onclick=\"PImgPlayer.play("+i+");return false;\" herf=\"javascript:;\" title=\"" + this._items[i].title + "\">" + (i+1) + "</span>"; ulHTML += "</li>"; } // var html = "<a href=\""+this._items[this._index].link+"\" title=\""+this._items[this._index].title+"\" target=\"_blank\" style=\""+linkStyle+"\"></a><ul style=\""+ulStyle+"\">"+ulHTML+"</ul>"; this._container.innerHTML = html; var link = this._container.getElementsByTagName("A")[0]; link.style.width = w + "px"; link.style.height = h + "px"; link.style.background = 'url(' + this._items[0].img + ') no-repeat center center'; // this._timer = setInterval( "PImgPlayer.play()", this.intervalTime ); }, addItem : function( _title, _link, _imgURL ){ this._items.push ( {title:_title, link:_link, img:_imgURL } ); var img = new Image(); img.src = _imgURL; this._imgs.push( img ); }, play : function( index ){ if( index!=null ){ this._index = index; clearInterval( this._timer ); this._timer = setInterval( "PImgPlayer.play()", this.intervalTime ); } else { this._index = this._index<this._items.length-1 "A")[0]; if(link.filters){ var ren = Math.floor(Math.random()*(link.filters.length)); link.filters[ren].Apply(); link.filters[ren].play(); } link.href = this._items[this._index].link; link.title = this._items[this._index].title; link.style.background = 'url(' + this._items[this._index].img + ') no-repeat center center'; // var liStyle = "margin:0;list-style-type: none; margin:0;padding:0; float:right;"; var baseSpacStyle = "clear:both; display:block; width:23px;line-height:18px; font-size:12px; FONT-FAMILY:'宋体'; opacity: 0.6;"; baseSpacStyle += "border:1px solid #fff;border-right:0;border-bottom:0;"; baseSpacStyle += "color:#fff;text-align:center; cursor:pointer; "; var ulHTML = ""; for(var i = this._items.length -1; i >= 0; i--){ var spanStyle = ""; if( i==this._index ){ spanStyle = baseSpacStyle + "background:#ff0000;"; //数字的颜色 } else { spanStyle = baseSpacStyle + "background:#c0c0c0;"; //数字的背景颜色 } ulHTML += "<li style=\""+liStyle+"\">"; ulHTML += "<span onmouseover=\"PImgPlayer.mouseOver(this);\" onmouseout=\"PImgPlayer.mouseOut(this);\" style=\""+spanStyle+"\" onclick=\"PImgPlayer.play("+i+");return false;\" herf=\"javascript:;\" title=\"" + this._items[i].title + "\">" + (i+1) + "</span>"; ulHTML += "</li>"; } this._container.getElementsByTagName("UL")[0].innerHTML = ulHTML; }, mouseOver : function(obj){ var i = parseInt( obj.innerHTML ); if( this._index!=i-1){ obj.style.color = "#ff0000"; } }, mouseOut : function(obj){ obj.style.color = "#fff"; } } --> </script> <div id="imgADPlayer"></div> <script> PImgPlayer.addItem( "拉手网", "http://www.lashou.com/", "./images/1001.jpg"); PImgPlayer.addItem( "糯米网", "http://www.nuomi.com/", "./images/1002.jpg"); PImgPlayer.addItem( "美团网", "http://www.meituan.com/", "./images/1003.jpg"); PImgPlayer.init( "imgADPlayer", 715, 95 ); </script> </body>
更多关于JavaScript相关内容感兴趣的读者可查看本站专题:《JavaScript切换特效与技巧总结》、《JavaScript查找算法技巧总结》、《JavaScript动画特效与技巧汇总》、《JavaScript错误与调试技巧总结》、《JavaScript数据结构与算法技巧总结》、《JavaScript遍历算法与技巧总结》及《JavaScript数学运算用法总结》
希望本文所述对大家JavaScript程序设计有所帮助。
华山资源网 Design By www.eoogi.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
华山资源网 Design By www.eoogi.com
暂无评论...
稳了!魔兽国服回归的3条重磅消息!官宣时间再确认!
昨天有一位朋友在大神群里分享,自己亚服账号被封号之后居然弹出了国服的封号信息对话框。
这里面让他访问的是一个国服的战网网址,com.cn和后面的zh都非常明白地表明这就是国服战网。
而他在复制这个网址并且进行登录之后,确实是网易的网址,也就是我们熟悉的停服之后国服发布的暴雪游戏产品运营到期开放退款的说明。这是一件比较奇怪的事情,因为以前都没有出现这样的情况,现在突然提示跳转到国服战网的网址,是不是说明了简体中文客户端已经开始进行更新了呢?
更新日志
2024年09月24日
2024年09月24日
- 纯音入心系列纯音乐《天籁古筝》1CD[MP3][331MB]
- 男女对唱典藏天碟《发烧对唱·那个季节里的歌DSD》10CD[WAV]
- 群星2010-歌林精选辑[歌林][WAV+CUE]
- TrioZimbalist-PianoTriosofWeinberg,Auerbach,Dvorak(2024)[24-44,1]wav
- 群星.1992-滚石第一流台湾歌·12王牌大车拼【滚石】【WAV+CUE】
- 林子祥.1984-创作歌集【华纳】【WAV+CUE】
- 周汤豪.2010-周汤豪【华纳】【FLAC分轨】
- Mozart-TheStringQuintets-AmadeusQuartet,CecilAronowitz(2017)[24-44,1][WAV+CUE]
- JamesWilliamsDennisIrwin-Focus(2024,Red)[24-48]FLAC
- 藤泽麻衣《空みあげて》[WAV]
- 纯音入心系列纯音乐《中国古筝经典名曲》1CD[MP3][1.3GB]
- 纯音入心系列纯音乐《古筝新奏:岁月静好与筝语,细水流年与筝同》1CD[MP3][846.9MB]
- 670《脆弱敏感小女生》[320K/MP3][27.53MB]
- 曾琳.2011-好好爱我【南方】【WAV+CUE】
- 范晓萱.1995-RAIN【福茂】【WAV+CUE】