Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

Q1690 How can I swap a larger image for a smaller image and vice versa?

You are here: irt.org | FAQ | JavaScript | Image | Q1690 [ previous next ]

The following works correctly in Internet Explorer 4+ and Netscape Navigator 6+:

<html>

<head>

<script language="JavaScript"><!--
function swap(target, source) {
  if (document.images) {
    document.images[target].src = document.images[source].src;
    document.images[target].width = document.images[source].width;
    document.images[target].height = document.images[source].height;
  }
}
//--></script>

</head>

<body>

<form>
<input type="button" value="Swap larger for smaller" onClick="swap('large','small')">
<input type="button" value="Swap larger for smaller" onClick="swap('small','large')">
</form>

<img name="large" src="banner0002.gif">

<img name="small" src="home0.gif">

</body>

</html>

Feedback on 'Q1690 How can I swap a larger image for a smaller image and vice versa?'

©2018 Martin Webb