做一个简单的Banner脚本相信网上看到的很多,但是很多其实并不好用,也不能满足要求.开始的时候随便写了一下,但是后来发现如果一个页面要放几个Banner,那就不好弄了.所以,就把整个写成一个class,这样子一个页面同时几个Banner都没有关系了.而且这样调用简单,而且又灵活.不管从哪方面来说,都是比较好的.banner效果:http://impx.net/scripts/tbanner.htm
希望这个功能对大家有帮助.
example: http://impx.net/scripts/tbanner.htm
/*=============================
Copyright by dragonimp
All rights reserved.
Description:class for Banners
version0.1 2004.8.26
version1.0 2004.11.24
Email:dragonimp@impx.net
HomePage:http://www.impx.net
==============================
//Usage:
//new Banner with string "banner_example" which should be the same as var. name banner_example
//init the base path of images, names of images, and urls for links
//start with interval time
var banner_example=new TBanner("banner_example");
banner_example.init("/images/rotate/",new Array("r1.gif","r2.gif","r3.gif"),new Array("url1","url2","url3"));
banner_example.start(5000);
==============================*/
//preload
function PreloadImages(images){
var preloadedimages=new Array()
for (p=0;p<images.length;p++){
preloadedimages[p]=new Image()
preloadedimages[p].src=images[p];
}
}
function Transbanner(the_image,new_image){
//var the_image=this.image;
//var images=this.images;
the_image.src=new_image;
the_image.style.visibility="hidden";
the_image.filters.item(0).Apply();
the_image.filters.item(0).Transition = Math.floor(Math.random() * 23);
the_image.filters.item(0).Play(2.0);
the_image.style.visibility="inherit";
}
function TBanner(bannerid){
this.imagepath="";
this.index=0;
this.image=new Image();
this.link=null;