473,544 Members | 2,411 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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=g o

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

function go() {
//alert("go?");
var pic=new Image();
pic.onload=yo; // method 1
//pic.addEventLis tener("load",yo ,false); // method 2
pic.src="sereni ty.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 5400


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*******@yaho o.de> wrote in message news:<42******* *************** *@newsread4.arc or-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
6175
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" onclick="document.all.someimage.src='someimage.jpg"> but how can i determine whether "someimage.jpg" is loaded? and can i get the download percent of a file? Thanks in advance
10
3568
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 language="JavaScript" type="text/javascript"> function show(that) { if (box.style.visibility=='hidden') { that.style.visibility = 'visible'}; }
3
1657
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 div containerDiv.setAttribute("id", "statusContainer");
1
1596
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 src="http://info.onet.pl/_i/galeria/okulary/15.jpg" onload="var xx=document.getElementById('xxx'); xx.innerHTML+='<BR>LOADED'"
4
2514
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 element (part of object/feature/bug detection). 2) There's a <form> element defined in the <body>, with the id 'theForm'. 3) The onload function...
3
26740
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 in firefox. The onload method I assign is never being called. Any ideas why firefox isn't calling this, or what I can do for a workaround? Below...
4
1797
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 = myImgLoaded and it fails on IE and FF. The reason being it's not returning a proper
6
1267
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() { if (window.complete) {
7
3142
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 load, an image.onload handler I've previously assigned will be called. Or should be at any rate. The problem is that I need to know inside the...
0
7438
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7374
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7783
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7392
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7720
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5309
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4930
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3422
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1850
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.