Search This Blog

Sunday 22 July 2018

1. Creating a webpage with two images which alternately changes on mouse over using CSS.

<html>
 <head>
   <title>Alternate Image Rollover</title>
 </head>
 <style type="text/css">
 Body{background-color:gray; font-size:12pt; text-align:center;}
 H1{font-size:22pt; color:blue; text-decoration:underline;}
 H3{font-size:18pt; color:yellow; text-decoration:underline;}
 img{border-style:groove;}
</style>
   
<script language="JavaScript">
if(document.images)
    flag = "yes";
else
    flag = "no";

if(flag=="yes")
{
    img1On = new Image();
    img1Off = new Image();
}
function imageSwitchOn(imagename)
{
    if(flag =="yes")
        document['img1'].src = "img1.jpg";
   
}
function imageSwitchOff(imagename)
{
    if(flag =="yes")
        document['img1'].src = "img2.jpg";
}
</script>
<body>
<H1>Image Rollover</H1><br>
<H3>Place your Mouse on the Picture</H3>
<A onMouseOver = "imageSwitchOn('img1')" onMouseOut="imageSwitchOff('img1')">
<img src = "img2.jpg"  height = 300 width =300 alt = "space" name = "img1">
</A>
</body>
</html>

No comments :

Post a Comment

FREE Hit Counters