Javascript DOM HTML Image complete Property get

Introduction

Check to see if the image is finished loading on body onload:

This property returns true if the image is finished loaded, and false if not.

View in separate window

<!DOCTYPE html>
<html>
<head>
<script>
function myFunction() {//from w  w  w.  ja v a 2 s .c om
  document.getElementById("demo").innerHTML ="Image loaded: " + document.getElementById("myImg").complete;
}
</script>
</head>

<body onload="myFunction()">
<p id="demo"></p>
<img id="myImg" src="image1.png" alt="The circle" width="100" height="98">

</body>
</html>



PreviousNext

Related