最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

dom events - How do you execute a JavaScript function when the page has fully rendered? - Stack Overflow

programmeradmin5浏览0评论

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.

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.

Share Improve this question edited Dec 27, 2022 at 10:18 Brian Tompsett - 汤莱恩 5,89372 gold badges61 silver badges133 bronze badges asked Jun 2, 2009 at 13:29 Omar KoohejiOmar Kooheji 55.8k71 gold badges186 silver badges243 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 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.)

发布评论

评论列表(0)

  1. 暂无评论