Wrox Home  
Search P2P Archive for: Go

  Return to Index  

javascript thread: Hide and view an image


Message #1 by "Marco van Schaijk" <marco.vanSchaijk@e...> on Tue, 20 Feb 2001 06:59:32
Thanks, This will do the trick.
Regards,

Marco van Schaijk
Systems Engineer
EDS
Netherlands Solution Centre (NLSC)
CC Application Development & Maintenance
Phone: 	+31-(0)181-502231
Fax:	+31-(0)181-502199
Mobile:	+31-(0)6-20570745
E-mail:	Marco.vanSchaijk@e...


-----Original Message-----
From: Andrew Thorne [mailto:AndrewT@C...]
Sent: dinsdag 20 februari 2001 15:58
Subject: RE: Hide and view an image


try this: below is an example of working code that contains 3 image
rollovers... I hope this helps :)

<html>
<head>
	<title>hide and view an image</title>
</head>
<script>
ImageName1Off = new Image(); ImageName1Off.src="Image1.gif"; // this is and
Image array 
ImageName1On = new Image();	ImageName1On.src="Image2.gif"; // it
contains the on and off states of the images

ImageName2Off = new Image(); ImageName2Off.src="Image1.gif"; // just change
the ImageName2 with your image name.
ImageName2On = new Image();	ImageName2On.src="Image2.gif"; 

ImageName3Off = new Image(); ImageName3Off.src="Image1.gif";
ImageName3On = new Image();	ImageName3On.src="Image2.gif"; 

function swapImage(ImageID,ImageName,DivID) {// this will work in IE and
Nutscrape ( uhh  I mean Netscape)
      (document.all)? (document.images[ImageID].src = eval(ImageName +
".src")) : (document.layers[DivID].document.images[ImageID].src 
eval(ImageName + ".src"));
      }
</script>
<body>
<div id="ImageName1" style="position:absolute; width:74px; left: 65px; top:
50px"> 
<a href="javascript:;"
onMouseOver="swapImage('ImageName1','ImageName1On','ImageName1'); return
true;" onMouseOut="swapImage('ImageName1','ImageName1Off','ImageName1');
return true;" class="ImageName1"><img name="ImageName1" src="Image1.gif"
border="0"></a> 

 
<a href="javascript:;"
onMouseOver="swapImage('ImageName2','ImageName2On','ImageName2'); return
true;" onMouseOut="swapImage('ImageName2','ImageName2Off','ImageName2');
return true;" class="ImageName1"><img name="ImageName2"  src="Image1.gif"
border="0"></a> 

<a href="javascript:;"
onMouseOver="swapImage('ImageName3','ImageName3On','ImageName3'); return
true;" onMouseOut="swapImage('ImageName3','ImageName3Off','ImageName3');
return true;"
class="ImageName3"><img name="ImageName3" src="Image1.gif" border="0">
</div>

</body>
</html>

-----Original Message-----
From: Marco van Schaijk [mailto:marco.vanSchaijk@e...]
Sent: Tuesday, February 20, 2001 3:00 AM
To: javascript
Subject: [javascript] Hide and view an image


Hello,

Is it possible to hide and view an image using client-side javascript?

Regards,
Marco van Schaijk
EDS Netherlands.


  Return to Index