Picture Slide Show

This script allows you to make a slide show with DHTML.  Make sure your pictures are the same size, or they will be forced to strech out or squeeze down to fit in the space.
 

 










Cut and paste the source code of the above script here (Read  How to Cut N Paste for help)

<!-------------Cut------------>
<HTML>
<HEAD>
<SCRIPT LANGUAGE="JavaScript1.2">
//    Script Editor:   Howard Chen
//    Browser Compatible for this script: IE 4.0 or Higher
//                                        Netscape 4.0 or Higher
//    Get more JavaScripts at http://www.geocities.com/SiliconValley/Network/7432/
//    Bug report to hchen007@geocities.com
//    This script is free as long as you keep its credits
var picName = new Array()
var pic = new Array()

//===================Setting , edit this part only===================

  //Load all pictures

picName[0] = "slide1.gif"               // Enter your images in this format
picName[1] = "slide2.gif"
picName[2] = "slide3.gif"

  //Then picture sliding info

var DivWidth = 200                      //Height of the pictures
var DivHeight = 100                     //Width of the pictures
var Speed = 50                          //Scrolling speed in miliseconds
var Distance = 5                        //Number of pixels scrolled at one time
var PositionLeft = -200                 //Position from the left side of the window
var PositionTop = 200                   //Position from the top of the window

//================Do not edit from this part on===================

for(var i=0; i < picName.length; i++)
{
pic[i] = new Image; pic[i].src = picName[i]
}



var n = (document.layers) ? 1:0
var ie = (document.all) ? 1:0

function init() {
        // initialize objects
        slider = new dynLayer("slideDiv")
        // initialize events
if (n) {
        windowWidth = window.innerWidth-16
        windowHeight = window.innerHeight
}
if (ie) {
        windowWidth = document.body.offsetWidth-20
        windowHeight = document.body.offsetHeight
}
slideShow()
}

function dynLayer(id,nestref) {
        if (n) {
                if (nestref) {
                        this.css = eval("document." + nestref + ".document." + id)
                        this.ref = eval("document." + nestref + ".document." + id + ".document")
                }
                else {
                        this.css = document.layers[id]
                        this.ref = document.layers[id].document
                }
                this.x = this.css.left
                this.y = this.css.top
                this.w = this.css.clip.width
                this.h = this.css.clip.height
        }
        else if (ie) {
                this.css = document.all[id].style
                this.ref = document
                this.x = this.css.pixelLeft
                this.y = this.css.pixelTop
                this.w = this.css.pixelWidth
                this.h = this.css.pixelHeight
        }
        this.obj = id + "Object"
        eval(this.obj + "=this")
        this.moveBy = dynLayerMoveBy
        this.moveTo = dynLayerMoveTo
}

function dynLayerMoveBy(x,y) {
        this.x += x
        this.css.left = this.x
        this.y += y
        this.css.top = this.y
}
function dynLayerMoveTo(x,y) {
        this.x = x
        this.css.left = this.x
        this.y = y
        this.css.top = this.y
}


var i = 0

function slideShow() {
slider.moveBy(Distance,0)
if(slider.x >= windowWidth){changePic();return}
setTimeout("slideShow()",Speed)
}

function changePic() {
i++
if (i < pic.length) {
        slider.ref.SHOWPAD.src = pic[i].src
        slider.moveTo(PositionLeft,PositionTop)
        slideShow()
        }
}

//-->
</SCRIPT>
</HEAD>
<BODY onLoad="init()">
<!-------This part goes together------>
<SCRIPT>
<!--
document.writeln('<STYLE TYPE="text/css">');
document.writeln('<\!--');
document.writeln('#slideDiv {position:absolute;left:' + PositionLeft + ';top:' + PositionTop + ';width:' + DivWidth + ';height:' + DivHeight + ';clip:rect(0,' + DivWidth + ',' + DivHeight + ',0);}');
document.writeln('-->');
document.writeln('</STYLE>');
//-->
</SCRIPT>
<DIV ID="slideDiv">
<SCRIPT>
<!--
document.writeln('<IMG NAME=\"SHOWPAD\" SRC=\"' + picName[0] + '\">');
//-->
</SCRIPT>
</DIV>
<!------------------------------------>
</BODY>
</HTML>
<!------------End------------->
IMPORTANT: The scripts provided in this page are free as long as you keep the credits in the code.  E-mail me or use Script Rebuild Service for additional help about Cut N Paste or to ask for a script that is just for you.

Post Your Script Home