DelphiFAQ Home Search:
General :: Web publishing :: JavaScript :: Events
Questions, answers and code examples dealing with javascript event handlers.


This list is sorted by recent document popularity (not total page views).
New documents will first appear at the bottom.

Featured Article

How can I execute javascript code when an image is loaded?


I need to display a certain part of my page after a big picture is loaded. How can I catch this event?


This can be done easily with the onload and onerror event handlers that all IMG elements have. In those handlers you can check whether the images is loaded by reading the complete property.

Here's an example for images with event handlers:

<img onload="alert(this.src + ' loaded completely')" src="pie.gif" name=sampleImage>
 // To check whether a certain image is loaded:
 if (document.images['sampleImage'].complete) {
   alert('yes, it is loaded already');

Generated 4:01:39 on Jul 13, 2020