Self Improvement Articles Directory - Reference And Education Articles - Debt Consolidation - Golf Clubs - Free Music Download

PDA

View Full Version : JavaScript preloading …?


cre8ive
Dec 7th 2007, 11:22 pm
I have the following code:

<script language="JavaScript1.2">
if (ie4||dom)
{
document.write('<div style="position:relative;width:'+(scroller_width+10)+';height:'+scroller_height+';overflow:hidden"><div id="canvas0" style="position:absolute; background: url(\'img/bk_industrynews.jpg\'); background-color:'+bgcolor+';width:'+scroller_width+';height:'+scroller_height+';top:'+scroller_height+';filter:alpha(opacity=20);-moz-opacity:0.2;"></div><div id="canvas1" style="position:absolute; background: url(\'img/bk_industrynews.jpg\'); background-color:'+bgcolor+';width:'+scroller_width+';height:'+scroller_height+';top:'+scroller_height+';filter:alpha(opacity=20);-moz-opacity:0.2;"></div></div>')
} else if (document.layers)
{
document.write('<ilayer id=tickernsmain visibility=hide width='+scroller_width+' height='+scroller_height+' background: url(\'img/bk_industrynews.jpg\'); bgColor='+bgcolor+'><layer id=tickernssub width='+scroller_width+' height='+scroller_height+' left=0 top=0>'+scrollercontent[0]+'</layer></ilayer>')
}
</script>

How can I preload ‘img/bk_industrynews.jpg’? This code works fine in Firefox, but IE6 keeps loading this image over and over. And thus, this page doesn’t work well.

ajsa52
Dec 7th 2007, 11:45 pm
Try this:


<script type="text/javascript">
var myImage = new Image();
myImage.src = "img/bk_industrynews.jpg";
if (ie4||dom)
{
...
}
</script>

cre8ive
Dec 8th 2007, 4:47 am
Try this:


<script type="text/javascript">
var myImage = new Image();
myImage.src = "img/bk_industrynews.jpg";
if (ie4||dom)
{
...
}
</script>


Nope. This doesn't really change anything.

I guess I need to use this preloaded image somehow, but I cannot figure out how ...