Image Preload Problem

Sinac

Erfahrenes Mitglied
Wenn ich den folgenden Code benutze, werden die Bilder zwar
vorgeladen, aber kurz vorm ende gehts nicht weiter und man muss
auf "Vorladen überspringen" klicken, warum?
Code:
Code:
<html>
<head>
<title></title>
<script language="JavaScript1.1">
<!--
var locationAfterPreload = "index3.html"
        var lengthOfPreloadBar = 250
        var heightOfPreloadBar = 3

        var yourImages = new Array("admoff.gif","admon.gif","back.gif","backon.gif","dl.gif","dloff.gif","dlon.gif","drach.gif","ebook.gif","exitoff.gif","exiton.gif","gboff.gif","gbon.gif","gbook.gif","homeoff.gif","homeon.gif","linkoff.gif","linkon.gif","links.gif","login.gif","sinac.gif","txtoff.gif","txton.gif","zw.gif")

if (document.images) {

        var dots = new Array()
        dots[0] = new Image(1,1)
        dots[0].src = "grey.gif"
        dots[1] = new Image(1,1)
        dots[1].src = "blue.gif"
        var preImages = new Array(),coverage = Math.floor(lengthOfPreloadBar/yourImages.length),currCount = 0
        var loaded = new Array(),i,covered,timerID

        var leftOverWidth = lengthOfPreloadBar%coverage
}

function loadImages() {

        for (i = 0; i< yourImages.length; i++) {
        preImages[i] = new Image()
        preImages[i].src = yourImages[i]
        }

        for (i = 0; i< preImages.length; i++) {
        loaded[i] = false
        }

        checkLoad()
}

function checkLoad() {

        if (currCount == preImages.length) {
                location.replace(locationAfterPreload)
                return
        }

        for (i = 0; i<= preImages.length; i++) {
        if (loaded[i] == false && preImages[i].complete) {
        loaded[i] = true
        eval("document.img" + currCount + ".src=dots[1].src")
        currCount++
        }
}

        timerID = setTimeout("checkLoad()",10)
}
// --></script>
</head>
<body bgcolor="black" vlink="#01E311" alink="#01E311" link="#01E311">
<center><br><br><br><br><br><br><br><br><br><br><br>
<font face="Verdana" size="1" color="#0091C6">
...loading images<br>
&nbsp;&nbsp;&nbsp;Please wait.<br>
<SCRIPT LANGUAGE="JavaScript1.1"><!--

if (document.images) {

        var preloadBar = ''
        for (i = 0; i < yourImages.length-1; i++) {
        preloadBar += '<img src="' + dots[0].src + '" width="' + coverage + '" height="' + heightOfPreloadBar + '" name="img' + i + '" align="absmiddle">'
        }

        preloadBar += '<img src="' + dots[0].src + '" width="' + (leftOverWidth+coverage) + '" height="' + heightOfPreloadBar + '" name="img' + (yourImages.length-1) + '" align="absmiddle">'

        document.write(preloadBar)
        loadImages()
}

document.write('<p><a href="javascript:window.location=locationAfterPreload">Vorladen überspringen</a></p>')
// --></SCRIPT>
</head>
</html>
 

Neue Beiträge

Zurück