Replace Image of a Different Size

[Total: 0    Average: 0/5]

This loads a new image of a different size and sets the size correctly for the replacement image.

Body Code:

<script>
var _i = new Image(100,50); _i.src="http://www.js-examples.com/images/logo.gif";
var _j = new Image(50,50); _j.src="http://www.js-examples.com/js/pic1.gif";
var Toggle = true;
function si(_v) 
{
  if (_v) document.images[0].src=_i.src;
  else document.images[0].src=_j.src;
  Toggle=!_v;
}
</script>

<table border=1 height=300 width=300>
<tr height=100% width=100%>
<td width=100% height=100% align=center valign=middle>
<a href="javascript:si(Toggle)"><img src="http://www.js-examples.com/js/pic1.gif" name=pic1></a>
</td>
</table>

Times Viewed: 0

Leave a Reply

Your email address will not be published. Required fields are marked *