Home Javascript Slideshow - Slideshow Sample 01
2010-09-07
Main Menu
external Links
Most Read
Support

If you like the products on these pages, your support is highly appreciated. Thank you very much!

Amount: 

JavaScript: Slideshow Sample01
Written by Andreas Berger   
Sunday, 01 March 2009 12:28

The first sample shows the standard configuration of the script. The starting basis: 1 page with 1 slideshow.

The file names "be_slide.html" and "be_slide.js" correspond with the file names in the sample that comes with the download of the script at JavaScript: slideshow. The following explanatory notes also refer to these files and show how to integrate the script from the HTML-page and set the parameters in the downloaded JavaScript be_slide.js.


be_slide.html - the webpage

The first step is to integrate the script into the webpage. To achieve this, it is linked from the HEAD-section of the page:
<script type="text/javascript" src="be_slide.js"></script>

The sample assumes, that the script is located in the same directory as the webpage, otherwise the path has to be adjusted.

The second step is to create a DIV-container in the BODY-section of your page, located where you want the slideshow to be displayed. Of importance is the IDENTITY of this DIV-container - in this sample it´s "slideshow" (id="slideshow"). It can be chosen, within the script we will set it as value of a parameter. The DIV-container can be positioned and styled as you want. This sample inserts on of the pictures - uploaded to a subfolder called "pics" - statically into the DIV-container to provide a fallback for visitors without JavaScript.
For visitors with JavaScript enabled this is of no importance, because the script replaces the content of the DIV-container with the slideshow.

<div id="slideshow" style="margin:25px;">
  <img src="pics/pic01a.jpg" style="width:400px;height:300px;" />
</div>

That´s it for the webpage.


be_slide.js - the scriptfile

Now we set the parameters in the scriptfile be_slide.js to fit our needs. The sample above uses the following values:

 

//*****parameters to set*****
 
var def_imges=new Array ('pics/pic01a.jpg', 'pics/pic01b.jpg', 'pics/pic01c.jpg');
    //In this array, set the pictures you want the slideshow to display.
 
var def_divid="slideshow";
    //The IDENTITY of the DIV-Containers,
    //we created to hold the slideshow
 
var def_picwid=400;
    //The width of the widest picture in pixel.
    //Notice: The script does not scale your pictures!
 
var def_pichei=300;
    //The height of the highest picture in pixel.
    //Notice: The script does not scale your pictures!
 
var def_backgr="#eeeeee";
    //The background-color of the slideshow. It is of importance
    //if you have pictures in your set, that do not fit the values
    //set above for width and height.
 
var def_sdur=3;
    //The time, a picture is shown between two transitions in seconds.
 
var def_fdur=1;
    //The time the transition should take
 
var def_steps=20;
    //The number of steps to blend from 0-100.
    //A value between 1-100, the higher the value
    // the smoother the transition.
 
var def_startwhen="y";
    //Should the slideshow start automatically?
    //"y" for Yes, "n" for No
 
var def_shuffle="y";
    //Should we start with a random picture?
    //"y" for Yes, "n" for No
 
var def_showcontr="y";
    //Should we show control-elements?
    //"y" for Yes, "n" for No
 
var def_contr=new Array('bwd.png','start.png','stop.png','fwd.png');
    //if you show control elements, you may choose between textlinks
    //and buttons. Into this array therefor insert either the text
    //you want to be displayed or the path to the image you want to
    //be used. If the script finds either .jpg or .gif or .png as the
    //ending of your input, it will display the image automatically.
    //The sort order of the elements displayed and therefor within this
    //array is: BACK - START - STOP - FWD
 
//****************************************************************
 

 


That´s it, have fun with the script!
Last Updated on Thursday, 26 November 2009 18:49
 
Comments (80)
Klasse Tool
50 Wednesday, 04 November 2009 21:14
0l2i
Ich wollte nur kurz ein Kompliment darlassen für das klasse Tool. Echt einfach zu integrieren und wirkt einfach schick. Die Buttons ans eigene Layout noch anpassen und perfekt :-)

Vielen Dank
@Erik
49 Thursday, 01 October 2009 20:08
A. Berger
Hi Erik!

The client side JavaScript does not know anything about the server side PHP, it not even knows that the page it resides in is not a static page so - a conflict is rather unlikely. A lot more probable is a mistake/misconfiguration. If you could provide a link to the page I will have a look at it.

Best regards
Andreas
php integration
48 Thursday, 01 October 2009 00:12
Erik
Hello all! I have been trying to integrate this lovely script into a simple php site for quite some time now and it won't work. Basically I have made a php version of an old html site where the slideshow DID work, and have taken the code and inserted it into the of the php file containing the tag. This works for other java scripts but not for this one. Maybe there is some sort of conflict? It also occurs to me that the buttons are not visible even though I put "y" where told. All help is much appreciated.
Ratschlag war gut
47 Sunday, 13 September 2009 21:52
Ninos
lol, weis ned wieso, aber hat super geholfen, danke :)
@Ninos
46 Sunday, 13 September 2009 16:28
A. Berger
Hallo Ninos!

Hast Du schon mal in Erwägung gezogen, dass es an den Änderungen liegen könnte, die Du am Script vorgenommen hast? Falls nicht, es wäre vielleicht einen Versuch wert, das Script im Original zu verwenden und zu sehen, was passiert.

Gruß
Andreas
selbes Problem
45 Sunday, 13 September 2009 15:56
Ninos
sry, es hier zuzuspamen, aber ich hab da var def_backgr="#c0c0c0"; angegeben, sogar deins versucht, immer noch selbes Problem :(
Kann es sein, dass es an was anderem liegt?
@Ninos
44 Sunday, 13 September 2009 15:02
A. Berger
Hallo Ninos!

Das passiert, wenn man keine Hintergrundfarbe (var def_backgr="#eeeeee";) gesetzt hat :)

Gruß
Andreas
Link zur Seite
43 Sunday, 13 September 2009 14:21
Ninos
Hallo Andreas,
der Link zur Seite lautet filary.de
Da müsstest du vielleicht bisschen warten, bis mal ein Bild kommt, welches breiter oder höher ist, als das andere :)
Dann solltest du erkennen, was ich meinte :)

Danke schonmals,
Ninos
@Caroline
42 Sunday, 13 September 2009 10:10
A. Berger
Hallo Caroline!

Um herauszufinden, ob die Slideshow funktioniert - müssten Sie sie verwenden :)

Auf der Seite Slideshow (im Menü links) kann man das Script herunterladen (bretteleben.de.slideshow.20090406.zip). Das Archiv enthält ein voll funktionsfähiges Beispiel. Unter anderem enthält es die Datei be_slide.js. Das ist das Script. Es beginnt mit dem Copyright, dann folgen die Parameter, dann das eigentliche Script. Sie haben auf Ihrer Seite lediglich den Block mit den Parametern eingebaut, das ist ein bisschen zu wenig.
Verwenden Sie das ganze Script - und die Sache wird besser laufen. Der Iframe ist übrigens nicht nötig.

Gruß
Andreas
Schade - Slideshow funktioniert nicht
41 Sunday, 13 September 2009 09:48
Caroline
Ich glaube, ich habe alles richtig gemacht und verlinkt, aber die Diashow funktioniert nicht (Aussteller)

http://www.gv-fehraltorf.ch/expo_8320/

Wäre der inline-Frame überhaupt nötig oder kann ich den DIV-Container direkt in die Tabellenzelle setzen?

Es wäre schade, wenn ich es nicht zum Laufen bekäme; besonders der Start mit Zufallsbild ist mir wichtig.

Danke für die Hilfe
Caroline