faqts : Computers : Programming : Languages : JavaScript : Images

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

5 of 15 people (33%) answered Yes
Recently 2 of 9 people (22%) answered Yes

Entry

Why doesn't onClick work when loading an image like a rollover on Netscape mac????

Jun 6th, 2001 21:41
Colin Fraser, Dave Pedowitz,


Without seeing the code it is a little difficult to make any sort of 
reasonable assessment of the problem. However, if you preload images 
used in rollovers then they will work as they should in NN for the Mac. 
Try : 
//This script preloads images into the cache on opening the document. 
	if (document.images) { 
		alias1 = new Image 
		alias2 = new Image
		alias1.src="mypic1.gif"
		alias2.src="mypic2.gif"
	}  //end if
//This function changes over images on all rollovers in the document
function chgImage (imgName,newImg ) {
	if (document.images) {
		document[imgName].src=eval(newImg+".src")
	}  //end if
} //end function
The above code is placed into the remote *.js file
To call the rollover in the page
<a href="mypage.html"
	onMouseOver="chgImage('pic0','alias2')"
	onMouseOut="chgImage('pic0','alias1')">
<IMG SRC="mypic1.gif" BORDER=0 NAME="pic0" ALT="Alternate Topic"></a>
Hope this is what you were looking for.