简体   繁体   English

当页面完全呈现时,如何执行Javascript函数?

[英]How do you execute a Javascript function when the page has fully rendered?

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. 当页面完全呈现(显示)时,您将如何执行Javascript函数我知道onLoad事件在页面加载时执行但在呈现之前执行。

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. 我以前通过使用0间隔的超时来解决这个问题,这似乎通常起作用,但对我敏感的感觉似乎有些不雅。

Is there a proper way to do this? 有没有正确的方法来做到这一点?

UI'm using prototype as my java script framework so answers that involve that are helpful, however I would have thought that this would be built into Javascript. UI'm使用原型作为我的java脚本框架所以答案涉及到有用,但我会认为这将内置到Javascript中。

The onload event fires when the page is fully rendered (including dependancies such as images). 页面完全呈现时会触发onload事件(包括图像等依赖项)。

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)? 也许你会把它与Prototype的dom:loaded事件混淆(在加载DOM但在包含所有依赖项之前触发)?

(To be honest, this sounds like an XY problem .) (说实话,这听起来像是一个XY问题 。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM