www.webdeveloper.com
Results 1 to 3 of 3

Thread: mouseover mouse out

  1. #1
    Join Date
    Nov 2014
    Posts
    2

    mouseover mouse out

    Hello,

    very new to Java Script and struggling with this mouseover, mouse out assignment.
    When I run the code I am getting three placeholders representing .gif any assistance would be greatly appreciated. Thanks in advance:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" “http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>

    <title>Chapter 6: Example 5</title>

    <script type="text/javascript">
    var myImages = new Array("usa.gif","canada.gif","jamaica.gif","mexico.gif","greenland.gif");
    function changeImg(that)
    {
    var newImgNumber = Math.round(Math.random() * 3);

    while (that.src.indexOf(myImages[newImgNumber]) != -1)
    {

    newImgNumber = Math.round(Math.random() * 3);
    }

    that.src = myImages[newImgNumber];

    return false;
    }

    </script> </head>
    <body>
    <img name="img0" src="usa.gif" border="0"
    onclick="return changeImg(this)" />

    <img name="img1" src="mexico.gif" border="0"
    onclick="return changeImg(this)" />

    <img onmouseover="bigImg(this)" src="greenland.gif" alt="greenland">
    <img onmouseout="normalImg(this)" src="greenland.gif" alt="greenland">


    </body> </html>

  2. #2
    Join Date
    Sep 2008
    Location
    Akron, OH
    Posts
    1,143
    Where are your normalImg and bigImg functions declared?

  3. #3
    Join Date
    Nov 2014
    Posts
    2
    Hi cbVision - thanks for your response = this is what I have come up with
    <title>Chapter 6: Example 5</title>

    <script type="text/javascript">
    var myImages = new Array("usa.gif","canada.gif","jamaica.gif","mexico.gif","greenland.gif");
    function changeImg(that)

    //Where are your normalImg and bigImg functions declared

    var myFunction = new Function("bigImg");
    function bigImg(this)

    var myFunction = new Function("normalImg");
    function normalImg(this)

    {
    var newImgNumber = Math.round(Math.random() * 3);

    while (that.src.indexOf(myImages[newImgNumber]) != -1)
    {

    newImgNumber = Math.round(Math.random() * 3);
    }

    that.src = myImages[newImgNumber];

    return false;
    }

    </script> </head>
    <body>
    <img name="img0" src="usa.gif" border="0"
    onclick="return changeImg(this)" />

    <img name="img1" src="mexico.gif" border="0"
    onclick="return changeImg(this)" />

    <img onmouseover="bigImg(this)" src="greenland.gif" alt="greenland">
    <img onmouseout="normalImg(this)" src="greenland.gif" alt="greenland">


    </body> </html>

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles