Entry
In IE5.5 Image is not loaded using JavaScript ?? What should I do to load image in IE5.5
May 3rd, 2001 05:01
Colin Fraser, ameet vasu,
This question is a little vague, but I suspect you are talking about a
rollover image. The page is loaded and the pointer is positioned over
the image and the script executs but all you get is the little red cross
and bounding box, but no image. Try this:
The first part sets up the images in a cache and performs the rollover
<SCRIPT>
//to cache images
if (document.images) {
arrowPink = new Image
arrowBlue = new Image
arrowRed = new Image
arrowBlue.src="normalimage.gif"
arrowPink.src="mouseoverimage.gif"
arrowRed.src="clickimage.gif"
} //end if
/*This function performs the actual rollovers in the document and
appears AFTER the above code*/
function chgImage (imgName,newImg ) {
if (document.images) {
document[imgName].src=eval(newImg+".src")
} //end if
} //end function
</SCRIPT>
The following link executes the call to the function above.
<a href='javascript:void' onMouseOver=chgImage('pic0','arrowPink')
onMouseOut=chgImage('pic0','arrowBlue')
onClick=chgImage('pic0','arrowRed')> <img src='image1.gif' border=0
name='pic0' alt='going nowhere'>
Note the single quote marks, this is the area where most mistakes are
made, people write their code as they normally would in HTML and use
double quote marks, they forget, I know, I do it all the time then
wonder why my code does not run as it should.
I hope this resolves your problem, otherwise, please ask your question
again.