Preloader funktioniert nicht
nameless-one
- javascript
Hiho,
ich habe von jmd. ein Bild-Preloader per JS bekommen. Nun habe ich da meine Bilder eingetragen, aber er läd die letzten beiden nie. Egal wie ich sie nenne! (Sie sind ja richtig benannt!) Auch wenn ich ein paar Entferne (auch die letzten) dann läd er bei den letzten beiden nicht weiter!
Wo liegt denn der Fehler bzw wie sollte das Script aussehen? Habe von JS wenig Ahnung! ;)
Hier die komplette Datei:
<html>
<head>
<meta http-equiv="Pragma" content="no_cache">
<title>I'm not nameless!</title>
<script language="JavaScript">
function info(text) {
window.status = text;
}
function weg() {
window.status = "";
}
</script>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style>
A:link { FONT-WEIGHT: BOLD; COLOR: #ffffff; TEXT-DECORATION: none }
A:visited { FONT-WEIGHT: BOLD; COLOR: #ffffff; TEXT-DECORATION: none }
A:hover { FONT-WEIGHT: BOLD; COLOR:#000000; TEXT-DECORATION: underline overline }
A:active { FONT-WEIGHT: BOLD; TEXT-DECORATION: none }
</style>
<script language="JavaScript1.2">
startingColor = new Array()
endingColor = new Array()
var yourImages = new Array ('img/bg.gif','img/3point2.gif','img/3point.gif','img/4point.gif','img/pfeil.gif','img/bg-frame.gif','img/bg-title.gif','img/mail.gif')
var locationAfterPreload = "index2.html"
var preloadbarWidth = 200
var preloadbarHeight = 10
var backgroundOfGradient = "#000000"
startingColor[0] = "f"
startingColor[1] = "f"
startingColor[2] = "f"
endingColor[0] = "0"
endingColor[1] = "0"
endingColor[2] = "0"
var gap = 3
if (!document.all) location.replace(locationAfterPreload)
var a = 10, b = 11, c = 12, d = 13, e = 14, f=15, i, j, ones = new Array(), sixteens = new Array(), diff = new Array();
var convert = new Array("0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"), imgLen = yourImages.length;
var loaded = new Array(), preImages = new Array(), currCount = 0, pending = 0, h = 0, hilite = new Array(), cover = new Array();
var num = Math.floor(preloadbarWidth/gap);
for (i = 0; i < 3; i++) {
startingColor[i] = startingColor[i].toLowerCase();
endingColor[i] = endingColor[i].toLowerCase();
startingColor[i] = eval(startingColor[i]);
endingColor[i] = eval(endingColor[i]);
diff[i] = (endingColor[i]-startingColor[i])/num;
ones[i] = Math.floor(diff[i]);
sixteens[i] = Math.round((diff[i] - ones[i])*15);
}
endingColor[0] = 0;
endingColor[1] = 0;
endingColor[2] = 0;
i = 0, j = 0;
while (i <= num) {
hilite[i] = "#";
while (j < 3) {
hilite[i] += convert[startingColor[j]];
hilite[i] += convert[endingColor[j]];
startingColor[j] += ones[j];
endingColor[j] += sixteens[j];
if (endingColor[j] > 15) {
endingColor[j] -= 15;
startingColor[j]++;
}
j++;
}
j = 0;
i++;
}
function loadImages() {
for (i = 0; i < imgLen; i++) {
preImages[i] = new Image();
preImages[i].src = yourImages[i];
loaded[i] = 0;
cover[i] = Math.floor(num/imgLen)*(i+1)
}
cover[cover.length-1] += num%imgLen
checkLoad();
}
function checkLoad() {
if (pending) { changeto(); return }
if (currCount == imgLen) { location.replace(locationAfterPreload); return }
for (i = 0; i < imgLen; i++) {
if (!loaded[i] && preImages[i].complete) {
loaded[i] = 1; pending++; currCount++;
checkLoad();
return;
}
}
setTimeout("checkLoad()",10);
}
function changeto() {
if (h+1 > cover[currCount-1]) {
var percent = Math.round(100/imgLen)*currCount;
if (percent > 100) while (percent != 100) percent--;
if (currCount == imgLen && percent < 100) percent = 100;
defaultStatus = "Loaded " + currCount + " out of " + imgLen + " images [" + percent + "%].";
pending--;
checkLoad();
return;
}
eval("document.all.cell" + (h+1) + ".style.backgroundColor = hilite[h]");;
h++;
setTimeout("changeto()",1);
}
defaultStatus = "Loaded 0 out of " + imgLen + " images [0%]."
// end hiding -->
</script>
</head>
<body bgcolor="#F6F7F7" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width=99% height=100% align="center">
<tr><td>
<center>
<script language="JavaScript1.2">
<!-- beging hiding
document.write('<table border="1" bordercolor="#68B2D8" cellpadding="0" cellspacing="0" width="' + preloadbarWidth + '"><tr height="' + preloadbarHeight + '" bgcolor="' + backgroundOfGradient + '">');
for (i = 0; i < num; i++) {
document.write('<td bordercolorlight="68B2D8" bordercolordark="ffffff" width="' + gap + '" id="cell' + (i+1) + '"></td>');
}
document.write('</tr></table>');
loadImages();
// end hiding -->
</script>
<br>
<font face="Geneva, Arial, Helvetica, san-serif" color="#000066" size="1"><a href="index2.htm"><font color="#999999"><b><font color="#666666">Vorladen
überspringen</font></b></font></a><font color="#666666"><br>
Best view with IE6 (coloured elements)</font></font>
</center>
</td></tr></table>
</body>
</html>
MfG, der namenlose Webmaster!
http://www.nameless-one.de :)
okay, hab schon jmd. gefunden der ihn richtig stellt! =)
Ciao,
http://www.nameless-one.de :)