JS实现图片幻灯片效果

<strong><font color=#008000>代码如下: <br _fckxhtmljob="1"></font></strong><textarea id=Angelia onmouseover=this.select(); style="WIDTH: 90%" rows=12 _fckxhtmljob="1">&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"&gt;
&lt;HTML&gt;
&lt;HEAD&gt;
&lt;TITLE&gt;JS实现图片幻灯片效果&lt;/TITLE&gt;
&lt;META NAME="Generator" CONTENT="EditPlus"&gt;
&lt;META NAME="Author" CONTENT=""&gt;
&lt;META NAME="Keywords" CONTENT=""&gt;
&lt;META NAME="Description" CONTENT=""&gt;
&lt;/HEAD&gt;
&lt;BODY&gt;
&lt;div align="center"&gt;&lt;div id=AdRotator&gt;&lt;/div&gt;&lt;input id="second"&gt;&lt;button onclick="adRotator.set(getRef('second').value)"&gt;set time&lt;/button&gt;&lt;/div&gt;
&lt;SCRIPT LANGUAGE="JavaScript"&gt;
&lt;!--
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 += '&lt;table style="border:1px solid #333333;"&gt;&lt;tr&gt;&lt;td style="font-size:9pt;font-family:tahoma;font-weight:bold;"&gt;'
_html += '&lt;div id="rotatorPlayer"'
+ ' style="' + _w + ''
+ ';height:"' + _h + '"'
+ '&gt;'
_html += '&lt;a href="' + ( _l[_c] ? _l[_c] : "javascript:void(0);" ) + '"&gt;';
_html += '&lt;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);"'
+ ' &gt;';
_html += (_t[_c]?('&lt;div align="center"&gt;' + (_c+1) + '. ' + _t[_c] + '&lt;/div&gt;'):'&lt;p&gt;&lt;/p&gt;');
_html += '&lt;/a&gt;';
_html += "&lt;/div&gt;";
_html += '&lt;div align="right"&gt;';
for(var i=0; i&lt;_p.length; i++)
_html += '&lt;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 + ')"')
+ '&gt;'
+ (i&gt;8?(i+1):('0'+(i+1)))+ '&lt;/span&gt; ';
_html += "&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;";
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();
//--&gt;
&lt;/SCRIPT&gt;
&lt;/BODY&gt;
&lt;/HTML&gt;
</textarea><br _fckxhtmljob="1"><input onclick="runEx('Angelia')" type=button value=运行代码 _fckxhtmljob="1"> <input onclick="CopyCode(FindObj('Angelia'));" type=button value=拷贝代码 _fckxhtmljob="1"> <input onclick=SaveCode(Angelia); type=button value=保存代码 _fckxhtmljob="1">[Ctrl+A 全选 提示:你可先修改部分代码,再点运行代码]&nbsp;&nbsp;
原文地址:https://www.cnblogs.com/winner/p/602345.html