当前页面: 开发资料首页 → Javascript 专题 → JavaScript版幻灯片效果
JavaScript版幻灯片效果
摘要: JavaScript版幻灯片效果
<tr>
<td>
method: adRotator.initialize(容器名id);
method: adRotator.add(图片地址[,文字项][,链接地址])
method: adRotator.play();
运行代码框
<textarea class=fm id=code rows=12 cols=78> HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<head>
New Document
</head>
<body>
<input id="second">
<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 += '
'
_html += '';
_html += '';
_html += (_t[_c]?('
' + (_c+1) + '. ' + _t[_c] + '
'):'');
_html += '';
_html += "
";
_html += '
';
for(var i=0; i<_p.length; i++)
_html += ''
+ (i>8?(i+1):('0'+(i+1)))+ ' ';
_html += "
</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://www.webjx.com/img/200406301.jpg","网页教学网幻灯片特效代码","http://www.webjx.com")
adRotator.add("http://www.webjx.com/img/200406302.jpg")
adRotator.add("http://www.webjx.com/img/200406303.jpg")
adRotator.add("http://www.webjx.com/img/200406304.jpg")
adRotator.add("http://www.webjx.com/img/200406305.jpg")
adRotator.play();
//
</script>
</body>
</textarea>
<input style="CURSOR: hand" onfocus=this.blur() onclick="runEx('code')" type=button value=运行代码> <input style="WIDTH: 95px; CURSOR: hand" onfocus=this.blur() onclick=cycode(code) type=button value=复制到剪贴板 name=Submit> <input style="CURSOR: hand" onfocus=this.blur() onclick=svcode(code) type=button value=另存代码> [Ctrl+A 全部选择 提示:你可先修改部分代码,再按运行]
</td>
</tr>
</table>
↑返回目录
前一篇:
xWin之JS版
后一篇:
用javascript封装的导航菜单