By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,624 Members | 1,740 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,624 IT Pros & Developers. It's quick & easy.

Opera and image object onload

P: n/a
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

Jul 23 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a


in********************@hotmail.com wrote:
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.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 23 '05 #2

P: n/a
Martin Honnen <ma*******@yahoo.de> wrote in message news:<42***********************@newsread4.arcor-online.net>...
in********************@hotmail.com wrote:
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.


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
Jul 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.