...

View Full Version : Help with a simple script...



SerenadeSP
10-12-2005, 11:55 PM
I need help on a rollover script...

Here's the mark-up. Can someone tell me what I did wrong?


<!-- Hidden Script

var d = newData ()
var name = d.mouseOver; mouseOut

function mouseOver()
{
document.r1.src ="epee1.png"
}
function mouseOut()
{
document.r1.src =rapier1.png"

// End of Hidden Script -->


(I know this is pretty simple, but I just started scripting in Java like 2 days ago...)

_Aerospace_Eng_
10-13-2005, 12:15 AM
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
<script type="text/javascript">
<!--
function mouseOver()
{
document.r1.src ="epee1.png"
}
function mouseOut()
{
document.r1.src ="rapier1.png"
}
//-->
</script>
</head>

<body>
<a href="#" onmouseover="mouseOver()" onmouseout="mouseOut()"><img src="rapier1.png" alt="" name="r1"></a>
</body>
</html>
I personally wouldn't use Javascript for a simple image rollover. I would use CSS. You might want to pass variables to your function so you don't end up having like 5 different functions that do the same thing with different names.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
<script type="text/javascript">
<!--
function changeImages(where,what){
document.getElementById(where).src=what;
}
//-->
</script>
</head>

<body>
<a href="#" onmouseover="changeImages('r1','epee1.png')" onmouseout="changeImages('r1','rapier1.png')"><img src="rapier1.png" alt="" name="r1" id="r1"></a>
</body>
</html>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum