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

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

P: n/a
On Oct 23, 10:36 am, Tuxedo <tux...@mailinator.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.onload = photo_preloaded(PARAMETER);
preload_image.src = 'images/photo.jpg';


function photo_preloaded(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?

function first_function (PARAMETER) {
preload_image = new Image(800,600);
preload_image.onload = function () { photo_preloaded(PARAMETER); };
preload_image.src = 'images/photo.jpg';

Oct 23 '08 #1
Share this Question
Share on Google+
1 Reply

P: n/a
Jorge wrote:
preload_image.onload = 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.
Oct 23 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.