PDA

View Full Version : onMouseOver


fmx
02-26-2004, 04:40 PM
ive looked at this code for so long i want to kick a hole in the monitor and pinch a loaf in it.
help... the onMouseOver will not work.
<html>
<head>
<title>table</title>
<script language="javaScript">
<!--
if (document.images) {
proOn = new Image(); proOn.src="profileOver.jpg";
proOff = new Image(); proOff.src="me.jpg";
}
function rollOn(imgName) {
if (document.images) {
document[imgName].src = eval(imgName + "On.src");
}
}
function rollOff(imgName) {
if (document.images) {
document[imgName].src = eval(imgName + "Off.src");
}
}
//-->
</script>
</head>

<body bgcolor="#ffffff" link="#ffffff" alink="#FFFFFF" vlink="#FFFFFF"><center><img src="logo.jpg" alt="dThom.com">
<table bgcolor="#FFFFFF" height="500" width="400" cellpadding="0" cellspacing="0" border="0">
<tr>
<td><img src="content.jpg"></td>

</tr>
<tr bgcolor="ffffff">
<td>
<table cellpadding="0" cellspacing="1">
<tr>
<td><a href="enter.html" onMouseOver="rollOn('pro')" onMouseOut="rollOff('pro')"><img src="me.jpg"></a></td>
</tr>
</table>
</td>

</tr>
</table>
</center>
</body>
</html>

Joe
02-26-2004, 04:44 PM
wrong forum, shoulda gone in the JavaScript forum ;)

<script language> is deprecated

use

<script type="text/javascript">

from what i can see you have ('pro') but shouldnt one of those be proOn and the other be proOff as dictated in your script?

im no wizard with JS so im probably wrong

Jon Hanlon
02-26-2004, 05:31 PM
You need specifically named image files for this to work.
Try putting in a trace:


function rollOn(imgName) {
if (document.images) {
alert("On - Need file called " + eval(imgName + "On.src"));

document[imgName].src = eval(imgName + "On.src");
}
}
function rollOff(imgName) {
if (document.images) {
alert("Off - Need file called " + eval(imgName + "Off.src"));
document[imgName].src = eval(imgName + "Off.src");
}
}

petervazed
02-26-2004, 07:56 PM
What do you want to call?
How?
With: the name......

img src="me.jpg" NAME="pro" border="0"></a>

:cool:

fmx
02-26-2004, 08:35 PM
im lost
does
function rollOn(imgName) {
if (document.images) {
document[imgName].src = eval(imgName + "On.src");
}
}

plus

onMouseOver="rollOn('pro')"

equal profileOver.jpg?

fmx
02-27-2004, 12:53 AM
problem solved
ty for the help.

function swap(roll){
if(roll==0) document.images.rollover.src = "me.jpg";
if(roll==1) document.images.rollover.src = "profileOver.jpg"
}

<img id="rollover" src="me.jpg" onmouseover="swap(1)"
onmouseout="swap(0)">