JS - Undefined error
In javascript, what is an undefined error? The report is saying one of my images is undefined (it's for a mouseover effect) - the code is pasted below.
<script language="JavaScript" type="text/javascript">
= 3 ) version = "n3";
if ( broswerName == "Microsoft Internet Explorer" && browserVer >=4 ) version ="e4";
if ( version == "n3" ¦¦ version == "e4" )
{
blank = new Image(163,34);
blank.src = "../../../images/comms%20news/blank.gif";
about = new Image(163,34);
about.src = "../../../images/comms%20news/about.gif";
pubs = new Image(163,34);
pubs.src = "../../../images/comms%20news/pubs.gif";
info = new Image(163,34);
info.src = "../../../images/comms%20news/info.gif";
press = new Image(163,34);
press.src = "../../../images/comms%20news/press.gif";
marketing = new Image(163,34);
marketing.src = "../../../images/comms%20news/marketing.gif";
web = new Image(163,34);
web.src = "../../../images/comms%20news/web.gif";
ni = new Image(163,34);
ni.src = "../../../images/comms%20news/ni.gif";
scotland = new Image(163,34);
scotland.src = "../../../images/comms%20news/scotland.gif";
wales = new Image(163,34);
wales.src = "../../../images/comms%20news/wales.gif";
}
function button_on ( imgName )
{
if ( version == "n3" ¦¦ version == "e4" )
{
butOn = eval ( imgName + "_on.src" );
document [imgName].src = butOn;
}
}
function button_off ( imgName )
{
if ( version == "n3" ¦¦ version == "e4" )
{
butOff = eval ( imgName +"_off.src" );
document [imgName].src = butOff;
}
}
// -->
</script>
sersun posted this at 03:17 — 22nd August 2001.
They have: 32 posts
Joined: Aug 2001
I'm not by any means a JS pro, but you can at least tell which line the error is on by typing "javascript:" in the address bar (no quotes).
Hope that helps
sersun
Suzanne posted this at 05:47 — 22nd August 2001.
She has: 5,507 posts
Joined: Feb 2000
1. blank2.src doesn't exist
2. the hard returns in the anchor tag are in your code or just for example here? Because they can seriously mess up JavaScript. Good rule of thumb: no hard returns except after a ; in JavaScript.
3. Spaces around = can also cause problems in some browsers.
Suzanne
jocanning posted this at 14:22 — 22nd August 2001.
They have: 22 posts
Joined: May 2001
Thanks, that helped
Jo
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.