Subject: Dreaded Object Required
Posted By: Adam H-W Post Date: 10/21/2004 12:00:19 PM
Hi

I've got a simple rollover (well, supposed to be simple) but I can't get the thing to work - 'Error, Object Required' is the error message I get; I've tried everything, even copying and pasting code that is working with the same script but it's just not having it!

Please help

here's the relevant code:

<script src="includes/java_function.js" language="javascript" type="text/javascript"></script>
<script language="JavaScript" type="text/javascript">

function imgOver() {
}

function imgOut() {
}
</script>


then below in the body this is the html for example:

 <a href="mailto:info@mysite.co.uk?subject=website%20enquiry" onmouseover="imgover('email')" onmouseout="imgout('email')">
                    <img src="image_bin/email_up.gif" alt="" name="email" width="161" height="11" border="0">

below is the script in the java_function.js file:

home_up = new Image
email_up = new Image
about_up = new Image
vehicles_up = new Image
terms_up = new Image

home_over = new Image
email_over = new Image
about_over = new Image
vehicles_over = new Image
terms_over = new Image

home_up.src = "image_bin/home_up.gif"
email_up.src = "image_bin/email_up.gif"
about_up.src = "image_bin/about_up.gif"
vehicles_up.src = "image_bin/vehicles_up.gif"
terms_up.src = "image_bin/terms_up.gif"

home_over.src = "image_bin/home_over.gif"
email_over.src = "image_bin/email_over.gif"
about_over.src = "image_bin/about_over.gif"
vehicles_over = "image_bin/vehicles_over.gif"
terms_over.src = "image_bin/terms_over.gif"

function imgOver(thisImg) {
    document[thisImg].src = "image_bin/" + thisImg + "_over.gif"
}
    
function imgOut(thisImg) {
    document[thisImg].src = "image_bin/" + thisImg + "_up.gif"
}

It's probably something very simple that's staring at me in the face!

thanks alot

Adam



Reply By: joefawcett Reply Date: 10/21/2004 12:06:12 PM
Your functions are called imgOver and imgOut but you call imgover etc. Object required in JavaScript nearly always means you've got the case wrong on a function name.

--

Joe
Reply By: Adam H-W Reply Date: 10/21/2004 1:41:28 PM
phew, thanks for that Joe - you just saved me from going completely demented

Reply By: joefawcett Reply Date: 10/21/2004 2:17:00 PM
Reminds me of when I first started playing with JavaScript, I spent hours staring at code that errored with "object reqired" because I had used "If" instead of "if"

--

Joe

Go to topic 21073

Return to index page 737
Return to index page 736
Return to index page 735
Return to index page 734
Return to index page 733
Return to index page 732
Return to index page 731
Return to index page 730
Return to index page 729
Return to index page 728