Program Code – Mouse Over event

This program written in simple HTML (Hyper Text Markup Language) and with using Javascript.It’s work on any browsers.

Onload event

The onload event occurs when an object has been loaded . onload is most often used within the <body> element to execute a script once a web page has completely loaded all content (including images, script files, CSS files, etc.).The onload event can be used to check the visitor’s browser type and browser version, and load the proper version of the web page based on the information.

syntax

<element onload="myScript()">
<html>
<head>
<title>On Mouse over event</title>
<script language="javascript">
function imageinit()
{	img1On=new Image();
	img1Off=new Image();
	img1On.src="Garden.jpg";
	img1Off.src="Dock.jpg";
}
function imageSwitchOn(imagename)
{
	imageOn=eval(imagename+"On.src");
	document[imagename].src=imageOn;
}
function imageSwitchOff(imagename)
{
	imageOff=eval(imagename+"Off.src");
	document[imagename].src=imageOff;
}
</script>
</head>
<body onLoad="imageinit()"> 
<center><h1>Image...</h1><br>
<h3><i>Place your mouse pointer on the picture</i></h3>
<a onMouseOver="imageSwitchOn('img1')" onMouseOut="imageSwitchOff('img1')"> 
<img src="star1.jpg" height=200 width=200 alt="space" name="img1"></a>
</center>
</body>
</html>

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.