Click to See Complete Forum and Search --> : JavaScript: Object expected


Metaphor
March 18th, 2003, 11:47 AM
A common error, since it's so damned general that noone understands what it's pointing at. ;)

Well. I've got myself a function in an external .js file.

function swapImage(imgID, imgFile) {
document.images[imgID].src = '/newdesign/images/menubuttons/' + imgFile;
}

Simple as can be, right? Right.

Then, naturally, I've got an onMouseOver on a link that goes:

<a href="" onMouseOver="swapImage('imgHome','home_down.gif')"><img name="imgHome" src="home.gif"></a>

I can't for the life of me see anything wrong. Am I stupid? Is javascript stupid? Is the answer to the question about life, the universe and everything not 42?

Metaphor
March 18th, 2003, 11:50 AM
Never mind. ^^

I was making an error in a completely different location that mungled the relative paths to the external .js. How stupid of me. :)

rpungin
April 7th, 2003, 11:14 AM
In general, use Mozilla/Netscape javascript console to get more meaningful error messages. Just type javascript: in the address bar.

Metaphor
April 7th, 2003, 12:12 PM
It wasn't even a javascript error, so I doubt that would help. But thanks.