Opera and image object onload

  • Thread starter inevercheckthisaddress
  • Start date
I

inevercheckthisaddress

I can't get Opera to fire an event when an image object's src has
loaded. The test code I'm using is this -

---------------------------------
window.onload=go

function yo() {
alert("yo");
}

function go() {
//alert("go?");
var pic=new Image();
pic.onload=yo; // method 1
//pic.addEventListener("load",yo,false); // method 2
pic.src="serenity.jpg";
}
---------------------------------

Code is in a file on it's own referenced from the xhtml. Using either
of the two methods indicated the function yo doesn't get called.

Code works as expected in Firefox, Mozilla, Konqueror, IE. If I
uncomment the alert in go() I can see that go does actually get called.
Nothing comes up in Opera's Javascript console.

Opera 7.54 on Linux, if that makes a difference.

Am I doing something wrong here?

thanks,

mike
 
M

Martin Honnen

I can't get Opera to fire an event when an image object's src has
loaded.

I have tried

var img = new Image();
img.onload = function (evt) {
alert(this.src + ' loaded.');
};
img.src = 'kiboInside.gif';

with Opera 7.50 on Win XP and on the first try the onload handler was
executed, on further attempts not, unless the whole HTML document with
the script was first executed.
But with the current Opera 8.00 Beta 2 that is available for Windows the
onload handler fired any time the above code is executed so I don't
think it makes sense filing a bug.
 
M

mike

Martin Honnen said:
I have tried

var img = new Image();
img.onload = function (evt) {
alert(this.src + ' loaded.');
};
img.src = 'kiboInside.gif';

with Opera 7.50 on Win XP and on the first try the onload handler was
executed, on further attempts not, unless the whole HTML document with
the script was first executed.
But with the current Opera 8.00 Beta 2 that is available for Windows the
onload handler fired any time the above code is executed so I don't
think it makes sense filing a bug.

I just got Opear 8.0 beta 2 for Linux and it works fine. I guess
there's a bug in 7.5x. Sigh. This sort of thing which puts makes
writing reliable cross browser stuff difficult. How on earth does one
code around a broken onload handler? Maybe I could browser sniff,
though Opera has it's very prominent identity changing options...
hmmmm.

mike
 

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,773
Messages
2,569,594
Members
45,119
Latest member
IrmaNorcro
Top