15.02.2013 Views

JavaScript Examples Bible - UserWorks Technologies

JavaScript Examples Bible - UserWorks Technologies

JavaScript Examples Bible - UserWorks Technologies

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

320<br />

IMG.complete<br />

<strong>JavaScript</strong> <strong>Examples</strong> <strong>Bible</strong>: The Essential Companion to <strong>JavaScript</strong> <strong>Bible</strong><br />

complete<br />

NN2 NN3 NN4 NN6 IE3/J1 IE3/J2 IE4 IE5 IE5.5<br />

Compatibility ✓ ✓ ✓ ✓ ✓ ✓<br />

Example<br />

To experiment with the image.complete property, quit and relaunch your<br />

browser before loading Listing 22-2 (in case the images are in memory cache). As<br />

each image loads, click the “Is it loaded yet?” button to see the status of the complete<br />

property for the image object. The value is false until the loading finishes;<br />

then, the value becomes true. The arch image is the bigger of the two image files.<br />

You may have to quit and relaunch your browser between trials to clear the arch<br />

image from the cache (or empty the browser’s memory cache). If you experience<br />

difficulty with this property in your scripts, try adding an onLoad event handler<br />

(even if it is empty, as in Listing 22-2) to your tag.<br />

Listing 22-2: Scripting image.complete<br />

<br />

<br />

<br />

function loadIt(theImage,form) {<br />

form.result.value = “”<br />

document.images[0].src = theImage<br />

}<br />

function checkLoad(form) {<br />

form.result.value = document.images[0].complete<br />

}<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!