Krzysiek S. wrote:
Example shows what I mean - it works well IE and Mozilla, but not in
Opera :(
(click an image):
<IMG src="http://info.onet.pl/_i/galeria/okulary/15.jpg"
onload="var xx=document.getElementById('xxx');
xx.innerHTML+='<BR>LOADED'"
onclick="this.src='http://info.onet.pl/_i/galeria/okulary/17.jpg'">
<DIV id=xxx>--</DIV>
I think that is a bug in Opera, you might want to file that, visit
http://www.opera.com/support/bugs/.
I don't see a simple workaround, I have tried to add an event listener
with addEventListener but that doesn't fire either if the src is changed.
What you could try is replacing the <img> element with a new one e.g.
function replaceImage (img, newURL) {
if (img.cloneNode) {
var newImg = img.cloneNode(false);
newImg.src = newURL;
img.parentNode.replaceChild(newImg, img);
}
}
<img id="image2"
alt="load test"
onload="alert(event.type);"
src="buttonOff.gif"
onclick="replaceImage(this, 'buttonOn.gif');">
--
Martin Honnen
http://JavaScript.FAQTs.com/