I find myself learning web development. And I just started reading about javascript. As a language, i don't have any trouble with it, but i come across an annoying situation:
I was just going to try my first javascript for a simple action: changing the src attribute of an <img>
. So let's imagine i have this code in index.html:
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<script type="text/javascript" language="javascript" charset="utf-8">
function activate(id)
{
document.images(id).src ="home-on.jpg";
}
function deactivate(id)
{
document.images(id).src ="home-off.jpg";
}
</script>
</head>
<body id="ID">
<img id="home" src="home-off.jpg"
onmouseover="activate('home')"
onmouseout="deactivate('home')"/>
</body>
</html>
The code works perfectly on google chrome (swapping the image when the mouse is over, and out). But I have no luck with firefox. Any help? advice?