Forum Moderators: open

Message Too Old, No Replies

Preloading images are these pre loaded or not?

Preloading images

         

piggybank1974

11:16 pm on Feb 9, 2003 (gmt 0)

10+ Year Member



now call me stupid but i'm trying to work out if i've got this right or not.

What I'm trying to do is have these images cached so things will work faster and for the life of me I cannot work out if i've done it or not. I got an idea I though i would copy the menu part to a floppy and try it from there but it does not seem as if they are cached, can you do it this way?

first here is my Menu script:

var press

function TheImage(image)
{
if (press==1)
document.vbadvanced.src="menuframe/VBAdvanced1.gif";

if (press==2)
document.vbmidway.src="menuframe/VBMidway1.gif";

if (press==3)
document.vbbasics.src="menuframe/VBBasics1.gif";

if (press==4)
document.maths.src="menuframe/MATHS1.gif";

if (press==5)
document.btec.src="menuframe/BTEC1.gif";

if (image==1)
{
document.vbadvanced.src="menuframe/VBAdvanced.gif";
press=1
document.getElementById('chd').innerText = "This gives you examples in Visual Basic Advanced.."
}

if (image==2)
{
document.vbmidway.src="menuframe/VBMidway.gif";
press=2
document.getElementById('chd').innerText = "This gives you examples in Visual Basic Intermediate.."
}

if (image==3)
{
document.vbbasics.src="menuframe/VBBasics.gif";
press=3
document.getElementById('chd').innerText = "This gives you examples on Visual Basic the basics.."
parent.mainleftframe.document.location = "menuframe/vbbasics/middleleftframe.html"
}

if (image==4)
{
document.maths.src="menuframe/MATHS.gif";
press=4
document.getElementById('chd').innerText = "This will give you different routines to use in your programs"
}

if (image==5)
{
document.btec.src="menuframe/BTEC.gif";
press=5
document.getElementById('chd').innerText = "This give you information and examples for the budding BTECer"
}

}

now my HTML part..

<HTML>

<HEAD>
<TITLE>HomePage</TITLE>
<SCRIPT language=JavaScript src="js/menu.js"></SCRIPT>
<script language="JavaScript">

function doPreload()

{
var the_images = new Array('menuframe/BTEC.gif','menuframe/BTEC1.gif');
preloadImages(the_images);
}

function preloadImages(the_images_array) {

for(var loop = 0; loop < the_images_array.length; loop++)
{
var an_image = new Image();
an_image.src = the_images_array[loop];
}

}
</script>

</HEAD>

<BODY BGCOLOR="000000" TEXT="FFFFFF" LINK="#0000FF" VLINK="#800080" ALINK="#FF0000" TOPMARGIN="0" BORDER=0 leftmargin="0" onload="doPreload();">

<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" STYLE="border-collapse: collapse; position:absolute; WIDTH=" HEIGHT="42" background="menuframe/blanker.GIF" bordercolor="#FFFFFF" width="100%">

<TR BORDER="0">

<TD WIDTH="100%" height="30"></TD>

<!-- BTEC -->
<TD WIDTH="90" height="30">
<IMG SRC="menuframe/BTEC1.gif"; NAME='btec' WIDTH="90" HEIGHT="30" onClick="TheImage(5)"></TD>

more code here...

</TR>
more code here.....
</TABLE>

</BODY>

</HTML>

So am i right is it cached? and if not how do i modify it to do so...

Thanks the greatful pig

korkus2000

6:04 pm on Feb 10, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It should be. When you create "new Image()" it should cache the image that is being referenced.

tedster

10:50 pm on Feb 10, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



There seems to be a bug in IE 5.5 and IE 6 when it comes to doing preloads through an array. It's not that such images don't end up in the cache - they do. But for some reason the browser still downloads the image from the server when it's called for by a user action, instead of using the cached image for nearly instant results. So the browser's internal reference to the cached image must be mis-labeled in some way.

As I said, this IE glitch seems to show up when arrays are used for preloading - which of course includes the standard MacroMedia code used by Dreamweaver (all those familiar "MM_" functions). This has made for some pretty pokey roll-overs in recent times.

piggybank1974

11:06 pm on Feb 10, 2003 (gmt 0)

10+ Year Member



hi korkus2000 & tedster

Thanks for your replies.

Microsoft again hmhmhm! I hope they fix this bug soon.

as it seem a pointless exersice in caching them in the first place..

Speed for my size was and is important but i will have to live with it I suppose.

the pig

So in the Table in the body i'm i calling them write?

To do what i want?

tedster

11:28 pm on Feb 10, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This thread about "bare bones" rollover code" [webmasterworld.com] can probably handle your questions. You'll see what the basic elements are, and you build up your code from there.