Re: How to pass a parameter via an image.onload function call?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jorge

    Re: How to pass a parameter via an image.onload function call?

    On Oct 23, 10:36 am, Tuxedo <tux...@mailina tor.comwrote:
    How is it possible to pass a parameter via a function that runs upon onload
    of an off-screen image? Like for example:
    >
    (...)
    >
    function first_function( PARAMETER){
    preload_image = new Image(800,600);
    preload_image.o nload = photo_preloaded (PARAMETER);
    preload_image.s rc = 'images/photo.jpg';
    >
    }
    >
    function photo_preloaded (PARAMETER){
    alert(PARAMETER )
    >
    }
    (...)
    >
    Is is possible to run the second function only if the image has been
    preloaded, with the parameter? If so, how would this be constructed?
    >
    Yes:

    function first_function (PARAMETER) {
    preload_image = new Image(800,600);
    preload_image.o nload = function () { photo_preloaded (PARAMETER); };
    preload_image.s rc = 'images/photo.jpg';
    }

    --
    Jorge.
  • Tuxedo

    #2
    Re: How to pass a parameter via an image.onload function call?

    Jorge wrote:
    [..].
    preload_image.o nload = function () { photo_preloaded (PARAMETER); };
    Thanks for posting this snipped! I understand it uses a so-called function
    literal, or unnamed function call. It works fine, and appears to be the
    most straighforward solution specifically for what I'd like to achieve.


    Comment

    Working...