This code runs as javascript and this code can also be used as VBScript. For that, you need to change line 4 to <script language=” VBScript”> and the HTML file should be opened on old Internet Explorer
<Html>
<Head>
<Title>Changing Image</Title>
<Script language="javascript" >
function imageinit()
{
img1on=new Image();
img1off=new Image();
img1switch=new Image();
img1on.src="Butterfly.jpg";
img1off.src="Parrots.jpg";
img1switch.src="Flowers.jpg";
}
function imageSwitch1(imagename)
{
image=eval(imagename+"on.src");
document[imagename].src=image;
}
function imageSwitch2(imagename)
{
image=eval(imagename+"off.src");
document[imagename].src=image;
}
function imageSwitch3(imagename)
{
image=eval(imagename+"switch.src");
document[imagename].src=image;
}
</script>
</head>
<body onload="imageinit()">
<center>
<H1>Image...</H1>
<br>
<H3><i>Click the Button to View the Image...</i></H3>
<img src="Garden.jpg" height=200 width=200 alt="space" name="img1">
<br>
<br>
<br>
<input type="button" value="Butterfly" onclick="imageSwitch1('img1')">
<input type="button" value="Parrots" onclick="imageSwitch2('img1')">
<input type="button" value="Flowers" onclick="imageSwitch3('img1')">
</center>
</body>
</html>