Multiple onLoad in Opera

M

Martin Honnen

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');">
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,019
Latest member
RoxannaSta

Latest Threads

Top