how to register an element onload when the element is not loaded?
<p>i've learned that you can register body onload like this:</p>

<pre><code>window.addEventListener('load', function, capture); // or attachEvent for ie; capture is true or false
</code></pre>

<p>so i tried to register an element onload like this:</p>

<pre><code>document.getElementById(eleid).addEventListener('load', function, capture);
</code></pre>

<p>but it gets me error, says "can not call method addeventlistener of null" or something like that.<br />
I think it's because the document.getElementById(eleid) doesn't exist yet when the registering occurs. but i need to register it before the element loads, what's the point of registering an onload function when the element is already loaded? the function will never get called.<br />
<br />
so the question is how do i register an element onload function then?</p>

<p><strong>Update:</strong></p>

<p>thanks to NSD, Pekka, and pygorex1, I now know that I can't register onload event for elements other than body and image<br />
<br />
so now the question is, is there a work around?</p>

<p>basically, what I want to do is show a div only if an image is loaded. onload works for images, so that's no problem. But sometimes the image is cached and loads before the div, and when the function tries to show the div, it can't find it. In that case, i want the div to show itself as soon as it comes into being.</p>

<p>any help would be appreciated</p>
