Home Javascript Slideshow - Slideshow Sample 01
2010-09-09
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)
Slideshow im Hintergrund
70 Monday, 22 March 2010 16:55
Martin Reichmann

Hi


auch von mir ein großes Dankeschön für das Script. Ich möchte mein statisches Bannerbild durch eine Slideshow ersetzen. Das ist mir mit ihrem JavaScript auch super gelungen. Allerdings war das ursprüngliche Bannerbild immer im Hintergrund und wurde von einem Text leicht überlagert.


Die Slideshow "drängt" sich jedoch immer in den Vordergrund. Ich habe versucht, innerhalb des JavaScripts mit dem Z-Index zu spielen. Blieb aber erfolglos.


Haben Sie mir eine Idee?


 


Hier mal die Seite:


http://www.netzwerk43.de/IndexFlashbanner


Aussehen sollte es aber so:


http://www.netzwerk43.de


 


Vielen Dank im Voraus

Slideshow im Hintergrund
Friday, 26 March 2010 11:19
Martin Reichmann

Den Z-Index des Text DIVs half leider auch nicht.


Ich habe die Position des Text DIVs nun in "absolute" geändert und die Position angepaßt. Jetzt funktionierts auch auf allen gängigen Browsern. Danke für die schnelle Antwort.

@Martin Reichmann
Monday, 22 March 2010 19:21
A. Berger

Hallo Herr Reichmann!

In diesem Fall bringt es nichts, am zIndex der Slideshow zu schrauben, die Werte dort sind ja selbst mit 1 und 2 schon zu hoch und ins Negative lassen sie sich nicht setzen. Man muss also dafür sorgen, dass der Inhalt des Artikels VOR der Slideshow und nicht die Slideshow HINTER dem Inhalt angezeigt wird. Langer Rede kurzer Sinn: Den zIndex des Inhalts auf zumindest 3 hochsetzen (Stylesheet des Templates).

Gruß
Andreas Berger

@Nina
69 Tuesday, 02 March 2010 19:44
A. Berger
Hallo Nina!

Ja, Du kannst den Parameter "def_backgr" auf "transparent" setzen. Das ist aber mit Vorsicht zu geniessen, denn wenn Du Bilder verschiedener Proportion verwendest, dann wird das nächste Bild - wo es grösser als das aktuelle ist - schlagartig sichtbar und nicht eingefadet.

Gruß
Andreas
Slideshow läuft nicht
68 Tuesday, 02 March 2010 08:45
Nina
Hallo Andreas,
vielen Dank für die Antwort. Habe den Fehler gefunden.
Das 'body onload' hat die Slideshow gestört. In einem iframe läuft sie jetzt.
Bis auf einen Wechsel klappt es. Da zeigt er nur den Hintergrund an, der sollte
bei mir allerdings druchsichtig sein...
Gibt es dafür eine Einstellung?
Danke und VG
Nina
@Nina
67 Monday, 01 March 2010 19:55
A. Berger
Hallo Nina!

Ja, es kann sein, dass ein anderes Script die Slideshow blockiert.

... hat Dir die Antwort geholfen?

Das habe ich befürchtet. Also, wenn Du einen Link zur Seite postest, dann schau ich mir das gerne an. In den meisten Fällen lassen sich derlei Probleme recht einfach lösen.

Gruß
Andreas
Slideshow läuft nicht
66 Monday, 01 March 2010 16:54
Nina
Hallo Andreas,
erst einmal vielen Dank für das schöne Script.
Leider bekomme ich es auf meiner HP nicht zum Laufen.
Kann es sein, dass ein anderes Java Script die Slideshow blockiert?
Habe noch eine vertikale Navi mit Java auf der Seite...
In einer extra Datei ohne weiteren Inhalt läuft die Slideshow ohne Probleme.
Die Pfade und alles müßten richtig sein.
Vielen Dank für Deine Antwort.
@Charlotte
65 Thursday, 25 February 2010 20:37
A. Berger
Hallo Charlotte!

Wenn Du Dir auf der Seite "Slideshow" (http://www.bretteleben.de/lang-de/javascript/slideshow.html) die Kommunikation mit Ingo Busch (Kommentare 119 und 120 vom 29.10.2009) ansiehst, dort ist erklärt wie das Script zu modifizieren ist.

Gruß
Andreas
keine Endlosschleife
64 Thursday, 25 February 2010 11:44
Charlotte
Hallo Andreas,
erst mal muss ich sagen das das Skript und die Erklärung dazu wirklich super sind.
Allerdings habe ich eine Frage zu der Endlosschleife. Im Gegensatz zum Matthias möchte ich dass das Skript beim letzten Bild stehen bleibt. Ist das über irgendeine Einstellung möglich?
Vielen Dank
Charlotte
@Matthias
63 Monday, 22 February 2010 20:54
A. Berger
Hallo Matthias!

Wunsch erfüllt! Das Script endet nicht mit dem letzten Bild sondern läuft in einer Endlosschleife (nimm Dir mal zwei, drei Tage Zeit, das anhand dieser Seite zu überprüfen). Wenn bei Dir nach dem letzten Bild Ende ist, dann geht irgend etwas schief. Ein Link zur Seite und ich schau mir das gerne an.

Gruß
Andreas
Repeat?
62 Monday, 22 February 2010 14:05
Matthias
Hallo,

tolles Script! Leider habe ich erst nach Einbau bemerkt, dass es nicht automatisch wiederholt.

Das würde ich mir wünschen.. :-)

Gruß Matthias
@bebra
61 Monday, 01 February 2010 18:48
A. Berger
Hallo bebra!

Unter dem Abschnitt "Joomla" im Menü links auf der Seite findest Du das "Simple Picture Slideshow" Plugin, das genau dafür entwickelt ist. Für die Darstellung von Slideshows in Joomla! Artikeln.

Gruß
Andreas