PDA

View Full Version : javascript preloader dont works in IE



Ingridk
12-25-2006, 02:19 PM
1) Script Title:
java script preloader I

2) Script URL (on DD):
( http://www.dynamicdrive.com/dynamicindex4/preloadit.htm)

3) Describe problem:
hey!
well, i'm trying to use the image prealoader script
,but only works in firefox. dont works in IE:( :(
somebody can help me?
here is my code

<html>
<head>
<title>carregando...</title>
<script language="JavaScript1.1" type="text/javascript">
<!--
var goTo = "http://www.vintagefelons.com/index2.htm"
var barWidth = 200
var barHeight = 13
var imgtoPreload = new Array("http://www.vintagefelons.com/myjukebox_files/body.jpg",
"http://www.vintagefelons.com/myjukebox_files/previous.jpg",
"http://www.vintagefelons.com/myjukebox_files/next.jpg",
"http://www.vintagefelons.com/images/index_r2_c18.jpg",
"http://www.vintagefelons.com/images/index_r12_c18.gif",
"http://www.vintagefelons.com/images/index_r12_c21.gif",
"http://www.vintagefelons.com/images/index_r5_c7.gif",
"http://www.vintagefelons.com/images/index_r5_c13.gif",
"http://www.vintagefelons.com/images/index_r1_c7.jpg",
"http://www.vintagefelons.com/images/index_r7_c12.gif",
"http://www.vintagefelons.com/images/index_r5_c15.jpg",
"http://www.vintagefelons.com/images/index_r5_c16.gif",
"http://www.vintagefelons.com/images/index_r5_c12.jpg",
"http://www.vintagefelons.com/images/index_r16_c6.gif",
"http://www.vintagefelons.com/images/index_r1_c17.gif",
"http://www.vintagefelons.com/images/index_r7_c15.gif",
"http://www.vintagefelons.com/images/index_r3_c2.jpg",
"http://www.vintagefelons.com/images/index_r1_c4.jpg",
"http://www.vintagefelons.com/images/index_r3_c3.gif",
"http://www.vintagefelons.com/images/index_r1_c1.gif",
"http://www.vintagefelons.com/images/index_r1_c7.jpg",
"http://www.vintagefelons.com/images/index_r6_c8.gif",
"http://www.vintagefelons.com/images/index_r9_c10.gif",
"http://www.vintagefelons.com/images/index_r7_c15.gif",
"http://www.vintagefelons.com/images/index_r3_c3.gif",
"http://www.vintagefelons.com/images/index_r4_c4.gif",
"http://www.vintagefelons.com/pages/home.jpg",
"http://www.vintagefelons.com/images/index_r10_c5.gif",
"http://www.vintagefelons.com/ambient1.gif",
"http://www.vintagefelons.com/ambient2.gif",
"http://www.vintagefelons.com/ambient3.gif",
"http://www.vintagefelons.com/umm.gif",
"http://www.vintagefelons.com/doiss.gif",
"http://www.vintagefelons.com/myjukebox_files/play.jpg",
"http://www.vintagefelons.com/myjukebox_files/play.jpg",
"http://www.vintagefelons.com/myjukebox_files/pause.jpg",
"http://www.vintagefelons.com/myjukebox_files/stop.jpg",
"http://www.vintagefelons.com/images/index_r10_c5.gif",
"http://www.vintagefelons.com/images/index_r18_c14.gif",
"http://www.vintagefelons.com/images/index_r16_c6.gif",
"http://www.vintagefelons.com/images/index_r2_c17.gif",
"http://www.vintagefelons.com/images/index_r5_c16.gif",
"http://www.vintagefelons.com/images/index_r13_c20.gif",
"http://www.vintagefelons.com/images/index_r17_c14.jpg",
"http://www.vintagefelons.com/images/index_r14_c18.gif",
"http://www.vintagefelons.com/images/index_r14_c19.jpg",
"http://www.vintagefelons.com/images/index_r15_c19.gif",
"http://www.vintagefelons.com/images/index_r5_c8.jpg",
"http://www.vintagefelons.com/images/index_r5_c9.gif",
"http://www.vintagefelons.com/images/index_r5_c10.jpg",
"http://www.vintagefelons.com/images/index_r5_c11.gif",
"http://www.vintagefelons.com/images/index_r17_c6.gif")
if (document.images) {
var barImg = new Array()
barImg[0] = new Image(1,1)
barImg[0].src = "black.gif"
barImg[1] = new Image(1,1)
barImg[1].src = "blue.gif"
var imgtoNow = new Array(),coverage = Math.floor(barWidth/imgtoPreload.length),currCount = 0
var loaded = new Array(),i,covered,timerID
var barWidthL = barWidth%coverage
}
function loadImages() {
for (i = 0; i < imgtoPreload.length; i++) {
imgtoNow[i] = new Image()
imgtoNow[i].src = imgtoPreload[i]
}
for (i = 0; i < imgtoNow.length; i++) {
loaded[i] = false
}
checkLoad()
}
function checkLoad() {
if (currCount == imgtoNow.length) {
location.replace(goTo)
return
}
for (i = 0; i <= imgtoNow.length; i++) {
if (loaded[i] == false && imgtoNow[i].complete) {
loaded[i] = true
eval("document.img" + currCount + ".src=barImg[1].src")
currCount++
}
}
timerID = setTimeout("checkLoad()",10)
}
//-->
</script>
</head>
<body bgcolor="black" text="white" link="white" alink="white" vlink="white">
<center>
carregando...
<script language="JavaScript1.1" type="text/javascript">
<!--
if (document.images) {
var preloadBar = ''
for (i = 0; i < imgtoPreload.length-1; i++) {
preloadBar += '<img src="' + barImg[0].src + '" width="' + coverage + '" height="' + barHeight + '" name="img' + i + '">'
}
preloadBar += '<img src="' + barImg[0].src + '" width="' + (barWidthL+coverage) + '" height="' + barHeight + '" name="img' + (imgtoPreload.length-1) + '">'
document.write(preloadBar)
loadImages()
}
//-->
</script>
<p>If the progress bar stops or does not move, please <a href="http://www.vintagefelons.com/index2.htm">click here</a>...
</center>
</body>
</html>

jscheuer1
12-28-2006, 04:16 PM
IE will halt execution of this script if one or more of the images is missing. FF will just skip to the next. This image is missing:

http://www.vintagefelons.com/myjukebox_files/stop.jpg

. . . appropriately named :)