views:

40

answers:

1

There are many dimensional functions, inside one of them we need to use onload event (do something when page is loaded).

The problem is the code inside $(window).load(function(){}); doesn't work. But it works outside the function.

Whats the problem?

+1  A: 

The event which triggers that function has already passed when the function containing the event listener gets executed?

ikanobori
I'm trying to run $(window).load() inside slideshow, to get know if next image is already loaded (need its height and width).
Happy
You know you also bind the load event to the image right? You could do `$('#id').load(function() { alert('hi'); })` to have the function executed when the image finished loading. See the documentation here: http://api.jquery.com/load-event/
ikanobori
A function which is registered in $(window).load() will only be called when the page is first loaded. If the window's "load" event was already fired when you go to register your event handler, the new handler will never be called.
RMorrisey