...

View Full Version : why isnt my onmouseover image changer not working



chopficaro
09-25-2012, 08:11 AM
when u mouse over the content the picture is supposed to change, but it doesnt
heres the js

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/

vwphillips
09-25-2012, 10:06 AM
you must pass a string to the function#

and function names and ID names must be unique


<!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>

chopficaro
09-25-2012, 11:08 AM
YES! thank u so much, works great now



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum