当 DOM 树完成时,如何让 Google Closure 调用我的 init 函数

发布于 2024-08-10 06:55:04 字数 203 浏览 4 评论 0原文

当我尝试使用 Closure 时,我正在寻找类似 jQuery 中的 $(document).ready 函数的东西。

所以,我的问题很简单,是否有一个我缺少的函数可以让我等到 DOM 树完成后调用我的函数?

我使用不显眼的 javascript,因此如果需要的话,将任何 javascript 放入我的 html 中的想法是负面的。

I am looking for something like the $(document).ready function in jQuery, as I work on experimenting with using Closure.

So, my question is simple, is there a function I am missing that will allow me to wait until my function is called when the DOM tree is done?

I use unobtrusive javascript, so the idea of putting any javascript in my html is such a negative, if that is required.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

千年*琉璃梦 2024-08-17 06:55:04

根据 这个。内联脚本块似乎是您唯一的选择。

Looks like you're out of luck according to this. Inline script blocks appears to be your only choice.

清风不识月 2024-08-17 06:55:04

如果您想按照自己的方式(而不是谷歌的方式)进行操作,也许这对您有用。

跨浏览器 JavaScript DOMContentLoaded

If you want to do it your way (instead of Google's way), perhaps this would work for you.

Cross Browser JavaScript DOMContentLoaded

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文