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>