PDA

View Full Version : Mouseover error message


Nel
05-07-2003, 07:21 PM
I keep getting error message 'document.foxtext1,2,3,4,5' is null or not an object!!!! Help I am a newbie
<HTML>

<HEAD>

<TITLE>HTML Rollovers</TITLE>

<SCRIPT LANGUAGE="JAVASCRIPT" TYPE="TEXT/JAVASCRIPT">

<!--Hide script from old browsers

if (document.images) {
fox1 = new Image
foxtext1 = new Image
fox2 = new Image
foxtext2 = new Image
fox3 = new Image
foxtext3 = new Image
fox4 = new Image
foxtext4 = new Image
fox5 = new Image
foxtext5 = new Image



fox1.src = "silverfox.jpg"
foxtext1.src = "construction.jpg"
fox2.src = "silverfox1.jpg"
foxtext2.src = "description.jpg"
fox3.src = "silverfox2.jpg"
foxtext3.src = "Power.jpg"
fox4.src = "silverfox3.jpg"
foxtext4.src = "tank.jpg"
fox5.src = "silverfox4.jpg"
foxtext5.src = "Amentities.jpg"


}
else {
fox1 = ""
foxtext1 = ""
fox2 = ""
foxtext2 = ""
fox3 = ""
foxtext3 = ""
fox4 = ""
foxtext4 = ""
fox5 = ""
foxtext5 = ""
document.fox1 = ""
document.fox2 = ""
document.fox3 = ""
document.fox4 = ""
document.fox5 = ""
document.foxtext1 = ""
document.foxtext2 = ""
document.foxtext3 = ""
document.foxtext4 = ""
document.foxtext5 = ""
}

//End hiding script from old browsers-->

</SCRIPT>

</HEAD>

<BODY bgcolor="ffffcc">
<h1 align="center"><font face="trebucher ms" color="green">Silver Fox Yacht For Sale</font></h1>
<br>
<hr>
<br>
<br>
<h2 align="center"><font color="green">Page 1</font></h2>
<table align="center" border="6" bordercolor="gray" cellpadding="5" cellspacing="5" cols="2" bgcolor="green">

<tr>

<td align="center" bgcolor="white" bordercolor="black"><a href="silverfox.html" onMouseover="document.foxtext1.src=foxtext1.src" onMouseout="document.foxtext1.src=fox1.src"><img src="silverfox.jpg" width="200" height="160" border="0" name="fox1" alt="Silver Fox";</a></td>
<td align="center" bgcolor="white" bordercolor="black"><a href="silverfox.html" onMouseover="document.foxtext2.src=foxtext2.src" onMouseout="document.foxtext2.src=fox2.src"><img src="silverfox1.jpg" width="200" height="158" border="0" name="fox2" alt="SilverFox rearview"></a></td>

</tr>

<tr>

<td align="center" bgcolor="white" bordercolor="black"><a href="boat.htm" onMouseover="document.foxtext3.src=foxtext3.src" onMouseout="document.foxtext3.src=fox3.src"><img src="silverfox2.jpg" width="200" height="112" border="0" name="fox3" alt="Close up"</a></td>
<td align="center" bgcolor="white" bordercolor="black"><a href="boat.htm" onMouseover="document.foxtext4.src=foxtext4.src" onMouseout="document.foxtext4.src=fox4.src"><img src="silverfox3.jpg" width="244" height="161" border="0" name="fox4" alt="Front view"></a></td>
</tr>

<tr>
<td align="center" bgcolor="white" bordercolor="black"><a href="silverfox.html" onMouseover="document.foxtext5.src=foxtext5.src" onMouseout="document.foxtext5.src=fox5.src"><img src="silverfox4.jpg" width="200" height="186" border="0" name="fox5" alt="Last picture"></a></td>
</tr>
</table>";

</script>
</body>
</html>
any suggestion would help::D

Vladdy
05-07-2003, 07:44 PM
goto www.mozilla.org and get mozilla 1.3
it has javascript console (along with a bunch of other development oriented features) that provides much more meaningfull inforamtion about an error compared to IE box.

Skyzyx
05-08-2003, 01:51 AM
First of all, you're getting the error because document.foxtext1 (etc.) doesn't exist in your document.

Secondly, you are calling your script in the HEAD... which happens before the rest of the document is even processed. You need to turn your script into a function, then call it on BODY ONLOAD.

Nel
05-08-2003, 02:52 AM
Because I am a newbie I am still a little confused.
I thought that my if and else should be in head?
According to my book it tells me to set it up this way.
I need more specific instructions. I am a slow one!!
Please help
<body onLoad="(document.images)"{
fox1=new image
fos2=new image.etc...

fox1.src etc....


fox1=""
foxtext1=""
etc

document.fox1=""
document.fox2=""
etc
{
function(do what?)
"
"
"

:confused:
Any help would be appreciated:D

Skyzyx
05-08-2003, 03:05 AM
No, no, no...

In the HEAD, you'd do this:

<script language="javascript" type="text/javascript">
<!--
function loadAll()
{
if (document.images)
{
fox1 = new Image();
foxtext1 = new Image();
fox2 = new Image();
foxtext2 = new Image();
fox3 = new Image();
foxtext3 = new Image();
fox4 = new Image();

... etc...
}
else
{
... other stuff...
}
}
//-->
</script>



And in the BODY, you'd do this...

<body onload="loadAll();">


And like I said about the document.foxtext1 stuff. There has to be an actual foxtext1 to refer to for your browser to not error.