|
|
|
|
|
Example 1: height and width
The following example shows the use of the height and width properties alongside images of varying dimensions:
<html> <head> <title>image example</title> <script language="javascript"> function init() { var image = new Array(); image[0] = document.getElementById('image1'); image[1] = document.getElementById('image2'); image[2] = document.getElementById('image3'); var output = document.getElementById('output'); var html = ''; var i; html = '<ul>'; for (i = 0; i < image.length; i++) html += '<li>image' + (i+1) + ': height=' + image[i].height + ', width=' + image[i].width + ', style.height=' + image[i].style.height + ', style.width=' + image[i].style.width + '</li>'; html += '</ul>'; output.innerHTML = html; } </script> </head> <body onload="init()"> <p>Image 1: no height, width, or style <img id="image1" src="http://www.mozilla.org/images/mozilla-banner.gif"></p> <p>Image 2: height=50, width=500, but no style <img id="image2" src="http://www.mozilla.org/images/mozilla-banner.gif" height="50" width="500"></p> <p>Image 3: no height, width, but style="height: 50px; width: 500px;" <img id="image3" src="http://www.mozilla.org/images/mozilla-banner.gif" style="height: 50px; width:500px;"></p> <div id="output"> </div>height and width are also properties of the EMBED, OBJECT, and APPLET objects, as well as the blah blah..
| mozilla.org | mailto:oeschger | bug 93108 |
|
|
|
|
|