[Javascript] Calling images only when needed.

beaglewriter at att.net beaglewriter at att.net
Tue Feb 15 07:18:26 CST 2005


 -------------- Original message ----------------------
From: Paul Novitski <paul at novitskisoftware.com>
> thumbnail:      <img id="image123" src="thumb123.jpg" />
> large image:    <img id="largeImage" src="" />
> JavaScript:     [onclick event attached to every thumbnail:]
>                  document.getElementById("largeImage").src = this.id;

An advantage of this method is that you can get it to degrade gracefully when JavaScript is disabled:

<a href="image123.jpg" onclick="document.getElementById('largeImage').src=this;return false;">
 <img src="thumb123.jpg" />
</a>

I've been using this approach on my recent album pages, and I've found that it works even in the Sidekick and Palm Blazer browsers.

gs



More information about the Javascript mailing list