[thelist] javascript image replace broken in gecko

danielEthan daniel at ionize.net
Fri Mar 7 12:07:01 CST 2003


Hi evolters,

I apologize to any that are seeing this post again. *Another* list
couldn't answer it. Teach me.

I have a menu with a widget to turn down. I've two images, one called
'expand' and one called 'collapse.' When the function is called from
the onclick, I want to not only change the display of an element, but
also change the src of the image. Here's my code:

// TOGGLE DISPLAY OF NAVIGATION
function toggleNavigation(object) {
	var id = StyleObject(object); // call function to identify element
correctly across browsers
	var img = "tgl" + object.substr(3); // set img to id for image (by
lopping off first three letters of id coming in)
	var objImg = document.images[img]; // shortcut
	//alert(objImg.src); // I'm seeing the source correctly when alerting

	if (id.display == "") {
		id.display = "none";
		objImg.src = "./images/navigation/expand.gif";
	} else if (id.display != "") {
		id.display = "";
		objImg.src = "./images/navigation/collapse.gif";
	}
}

The display part is working fine. The .src change is working okay in IE
(Mac) and Safari. It's not working in Gecko. Any help greatly
appreciated. I haven't tested yet on the PC. Any help would be great.
I'm sure I must be missing something small if it's working in two out
of three.




More information about the thelist mailing list