您好,欢迎访问一九零五行业门户网

类似CSDN图片切换效果脚本_javascript技巧

复制代码 代码如下:
/*---------------------------------------------------------------------------*\
| subject: rotate ad
| namespace: system.web.ui.webcontrols.mzrotateimage
| author: meizz
| created: 2006-11-11
| version: 2006-12-06
|-----------------------------------
| msn: huangfr@msn.com qq:112889082 copyright (c) meizz
| http://www.meizz.com/jsframework/ mit-style license
| the above copyright notice and this permission notice shall be
| included in all copies or substantial portions of the software
| changer: worm
| alterdate: 2009-09-15
\*---------------------------------------------------------------------------*/
//using(system.data.mzdataprovider);
//using(system.web.forms.mzbehavior);
//node{url, target, summary, img, alt}
function mzrotateimage()
{
mzdataprovider.call(this); this.statechangehandle(1);
this.width = 280;
this.height= 187;
this.timer = null;
this.interval = 10000;
this.duration = 2000;
this.activeindex = 1;
this.currentindex = 0;
this.floatcontrolbar = true;
this.usefilter = system.ie && mzbrowser.version>=5.5;
}
mzrotateimage.extends(mzdataprovider, mzrotateimage);
system.loadcssfile(system.resourcepath +/mzrotateimage.css, mzrotateimage_css);
mzrotateimage.prototype.render=function()
{
this.datainit(); this.images=new array();
var d = this.nodes = this.rootnode.childnodes;
for(var i=0; i{
this.images[i] = new image();
this.images[i].src = d[i].get(img);
}
var id=this.id=mzrotateimage_+this.hashcode,s=[];
var width = this.width = parseint(this.width);
var height = this.height = parseint(this.height);
s.push();
s.push();
if(this.usefilter) { if(d.length>0) //filter: revealtrans
{
var alt = d[0].get(alt), src = this.images[0].src;
s.push(1)
s.push( style=max-width:90%+(this.duration/1000)+)');
s.push( id='+ id +_img' style='border: none' width=+this.width+ height=+this.height+ />);
s.push(+alt+
);
}
}
else { for(i=0; i{
s.push(0) s.push( display: none;);
s.push( height: + height +px; overflow: hidden;'>);
s.push(s.push( target='+ (d[i].get(target) || _self) +'>);
s.push(s.push( src='+ this.images[i].src +'/>);
s.push(+d[i].get(alt)+
);
}
}
s.push(
s.push( id='+id+_controlbar' class='mzrotateimage_controlbar'>);
for(i=0;i);
s.push(
); s.push(
); s = s.join();
this.statechangehandle(2); this._onload();
return s;
};
mzrotateimage.prototype.statechangehandle=function(n)
{
this.readystate = n||0;
this.dispatchevent(new system.event(onreadystatechange));
};
mzrotateimage.prototype._onload=function()
{
var me=this;
if(mzelement.check(this.id))
{
this.statechangehandle(4);
if(this.usefilter) this.timer=
settimeout(function(){me.filter();}, me.interval+me.duration);
else
{
this._rotate = new mzbehavior.rotate(me.id +_imagebox,
{interval:me.interval,duration:me.duration});
this._rotate.addeventlisteners(onchange, function(e)
{
me.activeindex = e.target.activeindex;
me.currentindex = e.target.currentindex;
e= new system.event(onchange); e.target=me;
me.dispatchevent(e);
});
}
var a = mzelement.check(this.id+_controlbar).getelementsbytagname(input);
a[this.currentindex].classname = active;
this.addeventlisteners(onchange, function(e)
{
for(var i=0; iif(a.length>1)
{
a[e.target.activeindex].classname = active;
}
else
{
a[0].classname = active;
}
});
for(var i=0; i{
var f=new function(instance('+ this.hashcode +').focus(+ i +));
a[i].onmouseover = f; a[i].onclick = f;
}
}
else settimeout(function(){me._onload();}, 10);
};
mzrotateimage.prototype.focus=function(n)
{
cleartimeout(this.timer);
if(this.usefilter){this.activeindex=n; this.filter();}
else if(this._rotate) this._rotate.focus(n);
};
mzrotateimage.prototype.filter=function()
{
var me = this;
if(me.dispatchevent(new system.event(onchange)))
{
var img;
if(img=mzelement.check(me.id +_img))
{
var a = img.parentnode;
var n;
if(me.nodes.length==1)
n=0
else
n=me.activeindex;
this.currentindex = n;
this.activeindex = n+1>=me.nodes.length ? 0 : n+1;
var dv=mzelement.check(me.id +_div);
dv.innertext=me.nodes[n].get(alt);
a.href = (me.nodes[n].get(url) || #);
a.target = (me.nodes[n].get(target) || _self);
img.src=me.images[n].src;
img.alt=me.nodes[n].get(alt);
if(me.nodes.length >1)
{
img.filters.revealtrans.transition=23;
img.filters.revealtrans.apply();
img.filters.revealtrans.play();
}
}
}
me.interval = 5000;
this.timer=settimeout(function(){me.filter();}, me.interval+me.duration);
};
其它类似信息

推荐信息