Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Dec 2009
    Posts
    77
    Thanks
    2
    Thanked 0 Times in 0 Posts

    why isnt my onmouseover image changer not working

    when u mouse over the content the picture is supposed to change, but it doesnt
    heres the js
    Code:
    function menuimage(food)
    {
    document.getElementById('menuimage').src=food+".jpg";
    }
    window.onload = function () 
    {
        document.onmousemove = function (e) {
            e = e || window.event,mse=Mse(e);
            var img = document.getElementById('menuimage');
            img.style.left = mse[0]+17+"px";
            img.style.top = mse[1]+"px";
        }
    }
    function Mse(e)
    {
     if (window.event){
      var docs=[document.body.scrollLeft,document.body.scrollTop];
      if (!document.body.scrollTop)
      {
       docs=[document.documentElement.scrollLeft,document.documentElement.scrollTop];
      }
      return [e.clientX+docs[0],e.clientY+docs[1]];
     }
     return [e.pageX,e.pageY];
    }
    and heres the link
    http://mw3dailymedia.com/ckbargrill/

  • #2
    Senior Coder
    Join Date
    Mar 2005
    Location
    Portsmouth UK
    Posts
    4,518
    Thanks
    3
    Thanked 506 Times in 493 Posts
    you must pass a string to the function#

    and function names and ID names must be unique

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml"><head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>CK Bar & Grill : Manchester NH</title>
    <meta name="description" content="Excelent Bar and Grill with a cheerful staff and exquisite food and drink. Best Sea food in Manchester.">
    <meta name="keywords" content="Manchester restaurant, bar, sea food, Clam King, CK Bar and Grill, fine dining, restaurant, Manchester, NH">
    <link href="http://mw3dailymedia.com/ckbargrill/css/home.css" rel="stylesheet" type="text/css">
    <script src="http://mw3dailymedia.com/ckbargrill/javascript/menuimage.js" type="text/javascript"></script>
    <script language="JavaScript" type="text/javascript">
    /*<![CDATA[*/
    function MenuImage(food){
     document.getElementById('menuimage').src="http://www.vicsjavascripts.org.uk/StdImages/"+food+".jpg";
    }
    
    window.onload = function (){
        document.onmousemove = function (e) {
            e = e || window.event,mse=Mse(e);
            var img = document.getElementById('menuimage');
            img.style.left = mse[0]+17+"px";
            img.style.top = mse[1]+"px";
        }
    }
    function Mse(e)
    {
     if (window.event){
      var docs=[document.body.scrollLeft,document.body.scrollTop];
      if (!document.body.scrollTop)
      {
       docs=[document.documentElement.scrollLeft,document.documentElement.scrollTop];
      }
      return [e.clientX+docs[0],e.clientY+docs[1]];
     }
     return [e.pageX,e.pageY];
    }
    /*]]>*/
    </script></head>
    <body class="body">
    <div id="header">
    <img id="cklogo" src="http://mw3dailymedia.com/ckbargrill/pics/cklogo.gif" />
    </div>
    
    <div id="wholediv">
     <div id="leftdiv">
      <div id="" onmouseover="MenuImage('Egypt6')">
       <h1 onmouseover="MenuImage('Egypt7')"></h1>
       <h2 onmouseover="MenuImage('Egypt8')"></h2>
      </div>
      <div id="test1" onmouseover="MenuImage('Egypt6')">
       <h1 onmouseover="MenuImage('Egypt9')">test1</h1>
       <h2 onmouseover="MenuImage('Egypt10')">test1</h2>
      </div>
      <div id="test3" onmouseover="MenuImage('Egypt11')">
       <h1 onmouseover="MenuImage('Egypt7')">test3</h1>
       <h2 onmouseover="MenuImage('Egypt7')">test3</h2>
      </div>
     </div>
      <img id="menuimage" src="http://www.vicsjavascripts.org.uk/StdImages/Egypt5.jpg" />
     </div>
    
    
    <table width="965">
    <tr>
    <td class="footer" width="50%">
    <div align="left">
    <a href="index.html" target="_self">Home</a> | <a href="menu/">Menu</a> | <a href="specials/">Specials</a> | <a href="directions/">Directions</a> | <a href="order/">Order Online</a>
    <br />
    791 Second Street  Manchester, NH 03102 | (603) 669-2868
    </td>
    </div>
    <td class="footer" width="50%">
    <div align="right">
    <a href="http://www.facebook.com/pages/Manchester-NH/Mint-Bistro/102245167321" target="_blank">like us on facebook</a> <a href="http://www.facebook.com/pages/Manchester-NH/Mint-Bistro/102245167321" target="_blank"><img src="pics/facebook.jpg" align="absmiddle" border="0" height="28" width="28"></a>
    <br/>
    <a href="contact/">email us<img src="pics/mail.jpg" align="absmiddle" border="0" height="28" width="28"></a>
    </div>
    </td>
    </tr>
    </table>
    </body></html>
    Vic

    God Loves You and will never love you less.

    http://www.vicsjavascripts.org/Home.htm

    If my post has been useful please donate to http://www.operationsmile.org.uk/

  • #3
    New Coder
    Join Date
    Dec 2009
    Posts
    77
    Thanks
    2
    Thanked 0 Times in 0 Posts
    YES! thank u so much, works great now


  •  

    Posting Permissions

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