BACKGROUND SWITCHER ANIMATION

Moderator: HTML-Laie

Antworten
Benutzeravatar
Hape
Administrator
Beiträge: 336
Registriert: Fr 22. Mai 2020, 00:33

BACKGROUND SWITCHER ANIMATION

Beitrag von Hape »

Dieses Script rotiert automatisch durch eine Reihe von Hintergrundbildern, ähnlich einer Diashow. Fügen Sie beliebig viele Hintergrundbilder hinzu. Einfache Konfiguration von Wechselgeschwindigkeit und Hintergrundbildern.

Code: Alles auswählen

<script language="JavaScript"> 
// CREDITS:
// Free Fun JavaScript: Background Image Swapper
// by Peter Gehrig 
// Copyright (c) 2010 Peter Gehrig. All rights reserved.
// Permission given to use the script provided that this notice remains as is.
// Additional scripts can be found at http://www.fabulant.com

// IMPORTANT: 
// If you add this script to a script-library or a script-archive 
// you have to insert a link to http://www.fabulant.com
// right into the webpage where the script will be displayed.

// Put the background-images into the same folder as your webpage.
// Add the filnames of your background-images to the Array below (just replace 
// our background-images with your background-images) 
var slideurl=new Array("bgimage1.jpg","bgimage2.jpg","bgimage3.jpg","bgimage4.jpg","bgimage5.jpg","bgimage6.jpg")

// swapping speed (seconds)
var slidestandstill=1

// do not edit the code below
var timer


var imgpreload=new Array()
for (i=0;i<=slideurl.length-1;i++) {
	    imgpreload[i]=new Image()
	    imgpreload[i].src=slideurl[i]
}


var i_slideurl=0

slidestandstill=slidestandstill*1000

function swapimages() {
	document.body.background=slideurl[i_slideurl]
  	i_slideurl++
  	if (i_slideurl>=slideurl.length) {i_slideurl=0}
	timer=setTimeout("swapimages()",slidestandstill)	
}

window.onload=swapimages
</script> 
Demoseite dazu hier: Background Switcher Animation

Antworten