JavaScript img object property: complete
[this page | pdf | back links]
The complete property of the JavaScript
DOM object
corresponding to the HTML <img> element returns
whether the browser has finished loading the image underlying the <img> element.
EXAMPLE:
HTML USED IN THIS EXAMPLE:
<!DOCTYPE html>
<html> <!-- Copyright (c) Nematrian Limited 2018 -->
<head>
<style>
table,td,tr,th,caption {border: thin solid black; border-collapse: collapse;}
</style>
</head>
<body>
original element: <img src="NematrianLogo.png"><br>
resized version: <img id="element" src="NematrianLogo.png" style="width: 23px; height: 40px">
<table >
<tr><th>img properties (of resized image)</th><th>value</th></tr>
<tr><td>complete</td><td id="x1"></td></tr>
<tr><td>naturalHeight (i.e. not affected by resizing)</td><td id="x2"></td></tr>
<tr><td>naturalWidth (i.e. not affected by resizing)</td><td id="x3"></td></tr>
</table>
<script id="element">
var x = document.getElementById("element");
document.getElementById("x1").innerHTML = x.complete;
document.getElementById("x2").innerHTML = x.naturalHeight;
document.getElementById("x3").innerHTML = x.naturalWidth;
</script>
</body>
</html>
|
NAVIGATION LINKS
Contents | Prev | Next | JavaScript DOM (and BOM)