[thelist] What's wrong with my preloading?

Hershel Robinson hershelsr at yahoo.com
Tue Aug 14 09:13:13 CDT 2001


I am doing what I think is a normal image preload in Javascript:

<SCRIPT LANGUAGE='JAVASCRIPT'>
// I tried adding the var declaration to see if that
// would help, but it doesn't seem to
var Back_Norm
var Back_Over
if (document.images) {
  Back_Norm = new Image()
  Back_Norm.src = "ViewPipeline.gif"
  Back_Over = new Image()
  Back_Over.src = "ViewPipelineSwap.gif"
  Next_Norm = new Image()
  Next_Norm.src = "NextPage.gif"
  Next_Over = new Image()
  Next_Over.src = "NextPageSwap.gif"
}
function doMouseOver(theObject) {
  if (document.images)
    theObject.src = eval(theObject.name+"_Over.src")
}
function doMouseOut(theObject) {
  if (document.images)
    theObject.src = eval(theObject.name+"_Norm.src")
}
</SCRIPT>

When I use these for rollovers, however, it doesn't actually work--the
browser has to download the image each time:

  <input TYPE="image"
    ONCLICK="SearchForm.Tab.value = &quot;Back&quot;;
SearchForm.Action.value = &quot;SearchForm&quot;"
    NAME="Back"
    ONMOUSEOVER="doMouseOver(this)"
    ONMOUSEOUT="doMouseOut(this)"
    src="ViewPipeline.gif" width="230" height="53"
    tabindex=53>

  <input TYPE="image"
    ONCLICK="SearchForm.Tab.value = &quot;Back&quot;;
SearchForm.Action.value = &quot;SearchForm&quot;"
    NAME="Next"
    ONMOUSEOVER="doMouseOver(this)"
    ONMOUSEOUT="doMouseOut(this)"
    src="NextPage.gif" width="238" height="53"
    tabindex=53>

What am I doing wrong?

Thanks,
Hershel



_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com





More information about the thelist mailing list