Hey all,
Please tell me what is wrong with this code:
<script type="text/javascript" >
function createimg()
{
var img = new Image();
img.src='link/to/image';
img.alt='Next image'; img.id = 'span1'; img.style.zIndex = 10;
img.style.position = 'absolute'; img.style.display='block'; img.style.top = '130px';
img.style.padding='10px'; img.style.left='440px'; img.className ='dynamicSpan';
document.body.appendChild(img);
return img;
}
function al()
{
alert('loaded');
}
a = createimg();
a.onmouseover = al();
</script>
In specific the last part, where I'm trying to assign the 'onmouseover' event handler of a, which is an image element. It does not assign this event handler for some reason and just executes the function on page load instead.
What is wrong?
Tony