Opera and image object onload

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • inevercheckthisaddress@hotmail.com

    #1

    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

  • Martin Honnen

    #2
    Re: Opera and image object onload



    inevercheckthis address@hotmail .com wrote:
    [color=blue]
    > I can't get Opera to fire an event when an image object's src has
    > loaded.[/color]

    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/

    Comment

    • mike

      #3
      Re: Opera and image object onload

      Martin Honnen <mahotrash@yaho o.de> wrote in message news:<4232cecb$ 0$26549$9b4e6d9 3@newsread4.arc or-online.net>...[color=blue]
      > inevercheckthis address@hotmail .com wrote:
      >[color=green]
      > > I can't get Opera to fire an event when an image object's src has
      > > loaded.[/color]
      >
      > 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.[/color]

      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

      Comment

      Working...