当页面完全呈现时,如何执行Javascript函数? [英] How do you execute a Javascript function when the page has fully rendered?
问题描述
当页面完全呈现(显示)时,您将如何执行Javascript函数我知道onLoad事件在页面加载时执行但在呈现之前执行。
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.
我之前通过使用0间隔的超时解决了这个问题,这似乎通常很有效,但对我敏感的感觉似乎有些不雅。
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?
UI'm使用原型作为我的java脚本框架所以答案涉及到有用,但我会想到这会内置于Javascript。
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.
推荐答案
当页面完全呈现时(包括图像等依赖项),onload事件将触发。
The onload event fires when the page is fully rendered (including dependancies such as images).
也许你会把它与Prototype的 dom混淆:加载事件(在加载DOM但在所有依赖项都有之前触发已包括在内)?
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)?
(说实话,这听起来像 XY问题。)
(To be honest, this sounds like an X-Y problem.)
这篇关于当页面完全呈现时,如何执行Javascript函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!