SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    SitePoint Enthusiast
    Join Date
    May 2001
    Location
    London
    Posts
    40
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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">
    <!--
    browserName = navigator.appName;
    browserVar = parseInt ( navigator.appVersion );
    version = "n2";
    if ( browserName == "Netscape" && browserVer >= 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>



    <a href="info.htm"
    onMouseOver = "
    blank.src = info.src;
    window.status='info'; return true"
    onMouseOut = "
    blank.src = blank2.src;
    window.status =' ';
    return true"><img src="../../../images/comms%20news/three.jpg" border=0 width="30" height="34" name="info"></a></td>

  2. #2
    SitePoint Wizard
    Join Date
    Jul 2001
    Location
    The Netherlands
    Posts
    2,617
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Undefined means that the variable which you use inside a function has not been assigned a value to. For example take variable X. If you have the function:

    Function= X+1

    and you don't assign a variable to X, meaning X is undefined, you will get the undefined error.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •