[Javascript] Calling images only when needed.

Paul Novitski paul at novitskisoftware.com
Mon Feb 14 22:22:55 CST 2005


At 02:33 PM 2/14/2005, Peter-Paul Koch wrote:
>var x = document.createElement('img');
>x.src = 'path/to/image.jpg';
>document.someNode.appendChild(x);


Or alternatively, if you want to mark up your HTML in advance, you can 
reset the image src each time a thumbnail is clicked:

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;

Paul  





More information about the Javascript mailing list