Name: TBANNER
Function: Show multiple pictures links at the same location, and some effect switches are used
The same page can display multiple such banner, which does not affect each other
Features: Simple use
Category: TBANNER
Method: init (basepath, image, urls) // basepath is the directory where the image is located
// Images is an image file name
// URLS is the array of link addresses corresponding to each picture. If less than the picture, use the first address instead
STEFFECT (Filter, Fneffect) // Filter is filter name and parameter,
// fneffect is a name function, the prototype is Fneffect (OBJ), OBJ is the image object displayed
This function can change the filter parameters outside to make each effect different
START (DELAY) / / Start automatic playing picture link, Delay is the interval of each image switching time, MS
STOP () // Stop automatically switching pictures and links
Play () / / Switch a picture link, play the effect, generally not
example:
Var banner_example = new tbanner (); // Declare a log Banner_example, then call initialization
Banner_example.init ("images /", // Image base address
New Array ("r0.gif", "r1.gif"), // image name
New array ("
http://www.impx.net ")); // Corresponding picture link
//banner.seffect ("Progid:dximagetransform.microsoft.fade (Duration=2 )" "// set new effect, no, call the default
Banner_example.start (2000); // Start, set the picture switching time 2 seconds
Demo address:
http://impx.net/scripts/tbanner.htm
TBanner (2) in Jscript Posted on Saturday, February 12, 2005 11:28 PM
/ * Remove this class, move the original function, and add a setEffect to set the filter and effect! This will write a function from the outside to enhance the effect! And don't have to pass the object name to classes! Keeping the original compatible, only one STEFFECT is added, and of course Play and STOP. Demo Address: http://impx.net/scripts/tbanner.htm/
/ * ====================================== Copyright by Dragonimp All Rights Reserved. Description: Class for TBANNER VERSION0.1 2004.8.26 FIRST thought to make a class for banner version1.0 2004.11.24 simple function to support a banner version1.1 2004.12.10 basic effect in class version1.2 2005.2.6 setEffect to add other filters and effects Email: dragonimp@impx.net HomePage : http://www.impx.net=======================================//USAGE: (4 Stes to Run A Banner 0. First include this file in your source. 1. New Tbanner to Initialize a New Tbanner Object 2. INIT The Base Path of Images, Names of Images, And Urls for Links. First As default; 3 . setEffect to play unique effection If omitted, it will play with default effection 4. start with interval time.//example: var banner_example = new TBanner (); banner_example.init ( "/ images / rotate /", new Array.. ("R1.GIF", "R2.GIF", "R3.GIF"), New Array ("URL1", "URL2", "URL3")); //banner_example.seffect ("Progid: DXImageTransform.microsoft. Gradientwipe (duration = 1.5, gradientsize = 0.75, motion = forward), null) //banner_example.seter //banner_example.seffect ("ReveAltrans (Duration=2.0, Tranition=1 )" ,Function (obj) {Ibj.Filters[0].transition = Math.Floor (Math.random () * 23);}) banner_example.start (5000); // MilliseCond ========================= ====== * /
Function TBANNER () {// Create a Contianer // ============================================= This. container = document.createElement ( "div"); //document.body.appendChild(this.banner); this can not work at unstandard env var contianerID = "TBannerContainer _" this.container.uniqueID;. document.write ( "< Div ID = '" Contianerid "'> div> "); DELETE this.Container; this.container = evAl (ContianerID); this.Image = window.document.createElement (" img "); this.link = Window.document.createElement ("a"); this.Container.Appendchild (this.Link); this.Link.Appendchild (this.mage); // =============== ===================== this.id = "banner _" this.container.uniqueId; evAl (this.id "= this"); // set the Real bannerid as this objectThis.container.style.filter = "ReveAltra (Duration = 2.0, transition = 1)"; this.container.margin = 0; this.container.padding = 0; this.image.border = 0; this . Simage.Style.Filter = this.container.style.filter; this.Link.Alt = this.id; this.link.target = "_ blank"; this.index = 0; this.delayTime = 5000; this.timer = NULL;
// public:
THISINIT = Function (Basepath, Images, URLs) {this.imagebasepath = basepath; this.URLS = Urls; this.preloadImages (images); this.Switchbanner (); // show first banner} THIS.Start = function (moretime) {this.delaytime = (delayTime == null)? this.delaytime: delayTime; this.timer = setInterval (this.id ". Play ()", this.delaytime);} this. STOP = function () {WINDOW.CLEARTIMEOUT (this.timer); this.timer = null;} this.seffect = function (filter, fnswitch) {this.container.style.Filter = filter; this.Image.Style.Filter = filter; this.switcheffect = (fnswitch == null) function () {}: function;} // switch to next banner and play effection this.play = function () {obj = this.image; // this. Container Doesn't Work, Why ??? //obj.style.visibility="hidden "; obj.filters [0] .apply (); this.switchbanner (); obj.style.visibility =" visible "; obj .filters [0] .play (); this.switcheffect (obj);}; // private: // default effect action this.switcheffect = function (obj) {Obj.Filters [0] .transition = Math.Floor (Math.random () * 23);} // show next banner this.switchbanner = function () {var banner = this; if (banner.index Banner.Images [banner.index]; banner.index ; if (banner.index> = banner.Images.length) banner.index = 0;} // Load images before play this.PreloadImages = function (images) {var preloadedimages = new Array () for (i = 0; i