作者:BlueMiracle 时间: 2006-03-23 文档类型:原创 来自:蓝色理想
method: adRotator.initialize(容器名id);method: adRotator.add(图片地址[,文字项][,链接地址])method: adRotator.play();
运行代码框<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <TITLE> New Document </TITLE> <META NAME="Generator" CONTENT="EditPlus"> <META NAME="Author" CONTENT=""> <META NAME="Keywords" CONTENT=""> <META NAME="Description" CONTENT=""> </HEAD> <BODY> <div align="center"><div id=AdRotator></div><input id="second"><button onclick="adRotator.set(getRef('second').value)">set time</button></div> <SCRIPT LANGUAGE="JavaScript"> <!-- function adRotator() {}; adRotator.initialize=function(o) { // script by blueDestiny this._t = new Array(); this._l = new Array(); this._p = new Array(); this._i = new Image(); this._c = 0; this._f = false; this._o = o; this._timeout = null; this._html = ""; // configration. // @ image width // @ image height // @ rotator speed // @ filter type this._w = 450; this._h = 450; this._s = 4; this._x = 23; return this; }; adRotator.add=function(p,t,l) { with (this) { _p.push(p); _t.push(t); _l.push(l); }}; adRotator.load=function() { with (adRotator) { if( _i.readyState=='complete' ) { if(_p.length-1==_c) { _f = true; _c = 0; window.clearTimeout(_timeout); //getRef("AdRotator").innerHTML="complete"; adRotator.play(); } else { _c++; getRef(_o).innerHTML="total images " + _p.length + ", loading picture " + _c + ' ' + _i.readyState + "..."; _timeout=window.setTimeout(adRotator.load,10) } } else { getRef(_o).innerHTML="total images " + _p.length + ", loading picture " + _c + ' ' + _i.readyState + "..."; _timeout=window.setTimeout(adRotator.load,10) } }}; adRotator.play=function() { with (adRotator) { if( _f ) { _html = ""; _html += '<table style="border:1px solid #333333;"><tr><td style="font-size:9pt;font-family:tahoma;font-weight:bold;">' _html += '<div id="rotatorPlayer"' + ' style="width:' + _w + '' + ';height:"' + _h + '"' + '>' _html += '<a href="' + ( _l[_c] ? _l[_c] : "javascript:void(0);" ) + '">'; _html += '<img id="rotatorPic" src="' + _p[_c] + '"' + ' width="' + _w + '"' + ' height="' + _h + '"' + (_t[_c]?' title="' + _t[_c] + '"':'') + ' style="border:1px solid blue;FILTER:revealTrans(transition=' + _x + ',duration=1);"' + ' >'; _html += (_t[_c]?('<div align="center">' + (_c+1) + '. ' + _t[_c] + '</div>'):'<p></p>'); _html += '</a>'; _html += "</div>"; _html += '<div align="right">'; for(var i=0; i<_p.length; i++) _html += '<span' + ' style="border:1px solid #333333;padding:1px 5px 1px 5px;height:20px;text-align:center;cursor:' + (_c==i ? ('default;background-color:red;"') : 'hand;" onclick="adRotator.select(' + i + ')"') + '>' + (i>8?(i+1):('0'+(i+1)))+ '</span> '; _html += "</div></td></tr></table>"; getRef(_o).innerHTML = _html; getRef("rotatorPic").filters[0].Apply(); getRef("rotatorPic").filters[0].Play(); next(); } else { _i.src = _p[_c]; adRotator.load(); } }}; adRotator.next=function() { with (this) { (_p.length-1==_c) ? _c=0 : _c++; _timeout=window.setTimeout(adRotator.play,_s*1000); }}; adRotator.select=function(i) { with (this) { window.clearTimeout(_timeout); _c=i; adRotator.play(); }}; adRotator.set=function(second) { with (this) { window.clearTimeout(_timeout); if((/\d+/).test(second)==true) { _s=second; adRotator.play(); } else { alert("must be digit!") adRotator.play(); } }}; function getRef(id) { return (document.all?document.all(id):document.getElementById(id)); } adRotator.initialize("AdRotator"); adRotator.add("http://img1.qq.com/ent/20060218/3215110.jpg","aa","http://www.blueidea.com") adRotator.add("http://img1.qq.com/ent/20060218/3215111.jpg") adRotator.add("http://img1.qq.com/ent/20060218/3215112.jpg") adRotator.add("http://img1.qq.com/ent/20060218/3215113.jpg") adRotator.add("http://img1.qq.com/ent/20060218/3215114.jpg") adRotator.play(); //--> </SCRIPT> </BODY> </HTML> [Ctrl+A 全部选择 提示:你可先修改部分代码,再按运行]
经典论坛讨论帖:http://www.blueidea.com/bbs/NewsDetail.asp?id=2462939
出处:蓝色理想 责任编辑:moby
◎进入论坛网页制作、网站综合版块参加讨论
蓝色理想版权申明:除部分特别声明不要转载,或者授权我站独家播发的文章外,大家可以自由转载我站点的原创文章,但原作者和来自我站的链接必须保留(非我站原创的,按照原来自一节,自行链接)。文章版权归我站和作者共有。
转载要求:转载之图片、文件,链接请不要盗链到本站,且不准打上各自站点的水印,亦不能抹去我站点水印。
特别注意:本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有,文章若有侵犯作者版权,请与我们联系,我们将立即删除修改。