7

How would you go about executing a JavaScript function when the page is fully rendered (Displayed) I know that the onLoad event executes when the page is loaded but Before it's rendered.

I've previously solved this problem by using a timeout with a 0 interval, which seems to work usually, but seems a little inelegant to my delicate sensibilities.

Is there a proper way to do this?

I'm using prototype as my JavaScript framework so answers that involve that are helpful, however I would have thought that this would be built into JavaScript.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Omar Kooheji
  • 54,530
  • 68
  • 182
  • 238

1 Answers1

8

The onload event fires when the page is fully rendered (including dependancies such as images).

Perhaps you are confusing it with Prototype's dom:loaded event (which fires when the DOM is loaded but before all the dependancies have been included)?

(To be honest, this sounds like an X-Y problem.)

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335