Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PRELOADER NOT WORKING IN IE FINE IN FF

Status
Not open for further replies.

hugstable77

Programmer
Apr 21, 2006
7
US
found a javascript image preloader -- works fantastic in FF but it coughs at the very end in IE...
the url to see it choke is:

code is:
<html>
<head>
<title>Blu - Loading Images</title>

<script language="JavaScript1.1">
<!-- begin hiding

/*
Preload Image With Update Bar Script (By Marcin Wojtowicz [one_spook@hotmail.com])
Submitted to and permission granted to Dynamicdrive.com to feature script in it's archive
For full source code to this script and 100's more, visit */

// You may modify the following:
var locationAfterPreload = " // URL of the page after preload finishes
var lengthOfPreloadBar = 200 // Length of preload bar (in pixels)
var heightOfPreloadBar = 15 // Height of preload bar (in pixels)
// Put the URLs of images that you want to preload below (as many as you want)
var yourImages = new Array
("/_images/breakBetweenLogoAndBody.gif",
"/_images/brown.gif",
"/_images/conBackgr.gif",
"/_images/contBreak.gif",
"/_images/contLeftBackgr.gif",
"/_images/contRightBackgr.gif",
"/_images/header-welcome.gif",
"/_images/leftNavArrow_off.gif",
"/_images/leftNavArrow_on.gif",
"/_images/leftNavBackgr.gif",
"/_images/leftNavBreak.gif",
"/_images/logoShadowLeft.gif",
"/_images/logoShadowRight.gif",
"/_images/maroon.gif",
"/_images/right-bookYourEvent.gif",
"/_images/rightOtherBackgr.gif",
"/_images/right-OurPatrons.gif",
"/_images/right-staff.gif",
"/_images/right-upComingEvents.gif",
"/_images/topNavArrow_off.gif",
"/_images/topNavArrow_on.gif",
"/_images/logoBackground.gif",
"/_images/topNavBackgr.gif",
"/_images/topNavBlueBack.gif",
"/_images/topNavShadowLeft.gif",
"/_images/topNavShadowRight.gif",
"/_images/veryTOpBackground.gif")
// Do not modify anything beyond this point!
if (document.images) {
var dots = new Array()
dots[0] = new Image(1,1)
dots[0].src = "black.gif" // default preloadbar color (note: You can substitute it with your image, but it has to be 1x1 size)
dots[1] = new Image(1,1)
dots[1].src = "blue.gif" // color of bar as preloading progresses (same note as above)
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 = new Image()
preImages.src = yourImages
}
for (i = 0; i < preImages.length; i++) {
loaded = false
}
checkLoad()
}
function checkLoad() {
if (currCount == preImages.length) {
location.replace(locationAfterPreload)
return
}
for (i = 0; i <= preImages.length; i++) {
if (loaded == false && preImages.complete) {
loaded = true
eval("document.img" + currCount + ".src=dots[1].src")
currCount++
}
}
timerID = setTimeout("checkLoad()",10)
}
// end hiding -->
</script>

</head>

<body bgcolor="#97B0DC">

<center>
<font size="4">Blu - Loading Images<br>
are being preloaded...</font><p>
0%
<script language="JavaScript1.1">
<!-- begin hiding
// It is recommended that you put a link to the target URL just in case if the visitor wants to skip preloading
// for some reason, or his browser doesn't support JavaScript image object.
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><small><a href="javascript:window.location=locationAfterPreload">Skip Preloading</a></small></p>')
// end hiding -->
</script>
</center>

</body>
</html>
----------------------
what is wrong? am i using a reserved character? WHen i shorten it - it runs in IE
 
WHen i shorten it - it runs in IE

Shorten it to what? What are you cutting out?

This probably means the error is in the code you are removing, but knowing what is hard, as you've not told us what you cut out.

One thing you might want to consider is adding semicolon statement delimiters, as your code has a distinct lack of these.

Hope this helps,
Dan

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top