-
I have the same basic menu on each page and created the rollover code with Dreamweaver. It includes a preload. When looking at my site log it appears that every time a page is loaded it automatically calls the images again. If they are still in the browser cache why does it do this?
Would I be better to have the preload only on the main index page and then just let the browser call if it isn't in cache anymore on subsequent pages?
Added Later
I just noticed something weird which I can't understand
Looking at the source for my main page I see the following
<body text="#000000" bgcolor="#FFFFFF" link="#FFFFF0" vlink="#FFFFF0" alink="#FF0000" background="images/index_bg.jpg" onLoad="">
The onload is followed by ="" yet on my original on my hard drive it is onLoad="all the names of the rollover image files">
It seems to still work and I assume Dreamweaver changed this code at some point on a revision I made to my site. I did upgrade to Dreamweaver 4.0. Does the "" simply load all image files in the menu? Would I be better to put the names back in
-
dreamweaver's preload images function SUCKS!. I don't think I have EVER seen it work properly.
I would recommend using a simpler, cleaner version of the code.
Try this method:
<!-- rollover scripting -->
<script language="javascript">
<!--
if (document.images) {
contact_us_on = new Image();
contact_us_on.src = "images/contact_us_on.gif";
contact_us_off = new Image();
contact_us_off.src = "images/contact_us_off.gif";
}
function changeImages() {
if (document.images) {
for (var i=0; i<changeImages.arguments.length; i+=2) {
document[changeImages.arguments[i]].src = eval(changeImages.arguments[i+1] + ".src");
}
}
}
// -->
</script>
and call it using this method
<a href="contact_us.shtml" onmouseover="changeImages('contact_us','contact_us_on')" onmouseout="changeImages('contact_us','contact_us_off')"><img name="contact_us" src="images/contact_us_off.gif" alt="contact us" width="133" height="18" border="0"></a>