<script type="text/javascript">
function Img(name,src,url)
{
var img=new Image();
img.src=src;
this._src=src;//图片的地址
this._width=img.width;//图片的宽度
this._height=img.height;//图片的高度
this._name=name;//图片的名字
this._url=url;//图片的超链接
}
function Photo(id,imgList)
{
this._container=document.getElementById(id);//
this._timer=null;//时间控制器
this._pause=1;//停留时间
this._duration=1000;//变换时间
this._imgList=null;//图片列表
this._index=1;//下一张图片索引
this._tansition=23;
this._img=null;//加载图片列表
this.start(imgList);
}
Photo.prototype={
start:function(imgList)//开始变换图片
{
this._imgList=imgList;
this._img=document.createElement('img');
this._img.src=this._imgList[0]._src;
this._container.appendChild(this._img);
this._timer=setInterval(bindAsEvent(this,this.change),this._pause*1000+this._duration);//初始化时间控制器
if(isIE())
this._img.style.filter='revealTrans(Duration='+this._pause+',Transition='+this._transition+')'; },
change:function()//变换图片
{
if(isIE())
{
this._img.filters[0].apply();
this._img.filters[0].play();
}
this._img.src=this._imgList[this._index]._src;
this._index++;
if(this._index>=this._imgList.length)
{
this._index=0;
}
}, stop:function()//停止变换
{
clearInterval(this._timer);
},
again:function()//继续变换
{
this._timer=setInterval(bindAsEvent(this,this.change),this._pause*1000+this._duration);
}
};
window.onload=function()
{
var list=new Array();
list.push(new Img('1','1.jpg','http://www.baidu.com'));
list.push(new Img('2','2.jpg','http://www.google.com'));
new Photo('container',list);
}
</script>问题见标题
function Img(name,src,url)
{
var img=new Image();
img.src=src;
this._src=src;//图片的地址
this._width=img.width;//图片的宽度
this._height=img.height;//图片的高度
this._name=name;//图片的名字
this._url=url;//图片的超链接
}
function Photo(id,imgList)
{
this._container=document.getElementById(id);//
//this._container=document.getElementById("container");//
this._timer=null;//时间控制器
this._pause=1;//停留时间
this._duration=1000;//变换时间
this._imgList=null;//图片列表
this._index=1;//下一张图片索引
this._tansition=23;
this._img=null;//加载图片列表
this.start(imgList);
}
Photo.prototype=
{
start:function(imgList)//开始变换图片
{
_imgList = imgList;
_img=document.createElement('img');
_img.src=_imgList[0]._src;
this._container.appendChild(_img);
_index = 1;
_timer=setInterval(this.change,this._pause*1000+this._duration);//初始化时间控制器
if(isIE)
_img.style.filter='revealTrans(Duration='+this._pause+',Transition='+this._transition+')';
},
change:function()//变换图片
{
if(isIE)
{
//_img.filters[0].apply();
//_img.filters[0].play();
}
_img.src=_imgList[this._index]._src;
this._index++;
if(this._index>=this._imgList.length)
{
_index=0;
}
},
stop:function()//停止变换
{
clearInterval(this._timer);
},
again:function()//继续变换
{
_timer=setInterval(this.change,this._pause*1000+this._duration);
},
isIE:function()
{
var navigatorName = "Microsoft Internet Explorer";
var aaaaa = false;
if( navigator.appName == navigatorName )
aaaaa = true;
return aaaaa;
}
};
function isIE()
{
var navigatorName = "Microsoft Internet Explorer";
var isIE = false;
if( navigator.appName == navigatorName )
isIE = true;
return isIE;
}
window.onload=function()
{
var list=new Array();
list.push(new Img('1','ProgressFiller.gif','http://www.baidu.com'));
list.push(new Img('2','lib_grippy.gif','http://www.google.com'));
new Photo('container',list);
}
</script>
这两句_img.filters[0].apply();//_img.filters[0].play();我机器上用不了,不知道为什么,所以注释掉了