Image

JavaScript stores images in the images array of the document object. A user may create a new image object as follows:

var new_image = new Image();

This statement creates a new image and sets its src property to a GIF or JPEG, then preloads that file. See Chapter 4 for more information about images and preloading.

Properties

align

FF, IE 4

Orientation of an image relative to the surrounding text. Values can be: absbottom, absmiddle, baseline, bottom, left, middle, right, texttop, top

alt

FF, IE 4

alt text of an image

border

FF, IE 4

Size of the border around the image

Example:

var the_border_size = window.document.my_image.border;

complete

FF, IE 4

Read-only: true if the image has completely downloaded and false otherwise

Example:

if (window.document.pretty_bird.complete) ...

Get The Book of JavaScript, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.