473,385 Members | 1,838 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Opera and image object onload

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
2 5389


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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
by: Donjuan | last post by:
Hi all I have trouble with tracking whether my image file is loaded. i use DHTML to change my image. HERE is the code: <img name="someimage" src="1.jpg"...
10
by: tony kulik | last post by:
This code works fine in ie and opera but not at all in Mozilla. Anybody got a clue as to how to get it right? <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <script...
3
by: Michael Phillips | last post by:
Hello I am trying to use DOM to create an object in a document and wish to be compativle with Opera My code is containerDiv = document.createElement("div"); //create download container...
1
by: Krzysiek S. | last post by:
Hi, I need your help. How to get multiple onLoad in Opera (v.7)? Example shows what I mean - it works well IE and Mozilla, but not in Opera :( (click an image): <IMG...
4
by: Howard Jess | last post by:
In Opera 8.01 (Linux; Build 1204) and in Opera 7.54 (Windows XP; Build 3865), my form disappears from the HTML markup (below). To summarize: 1) In a <script> block in the <head> I create a form...
3
by: jon | last post by:
Hello, I've had long standing code that runs in IE, that I'm testing with firefox unsuccessfully now. The problem seems to be that images that I dynamically create don't fire their onload event...
4
by: Mark S. | last post by:
Hello, On a high volume page we have the following JavaScript: img = new Image() img.src = 'http://myserver.com/count.aspx?x=1'; and it works fine, but now we've added: img.onload =...
6
by: Janwillem Borleffs | last post by:
Tuxedo schreef: You can check the Image.complete property; example: img = new Image(100,100); interval = setInterval('checkcomplete()', 100); img.src = 'someimg'; function checkcomplete()...
7
by: howardk | last post by:
I'm writing some code that loads a number of images, using the standard mechanism of assigning a src url to a newly constructed Image object, thus invoking the image-load operation. On a successful...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.