I need some javascript code that dynamically adds an img tag to a div, and the img tag needs onmouseover and onmouseout handlers.
I have it working on Firefox. But
if (img.addEventListener) {
img.addEventListener('mouseover', function() {}, false);
img.addEventListener('mouseout', function() {}, false);
} else { // IE
img.attachEvent('onmouseover', function() {});
img.attachEvent('onmouseout', function() {});
}
look into using one of the many popular javascript libraries (jquery, prototype, etc). they hide browser inconsistencies so you don't need to worry about writing code like above.