当 DOM 树完成时,如何让 Google Closure 调用我的 init 函数
当我尝试使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
根据 这个。内联脚本块似乎是您唯一的选择。
Looks like you're out of luck according to this. Inline script blocks appears to be your only choice.
如果您想按照自己的方式(而不是谷歌的方式)进行操作,也许这对您有用。
跨浏览器 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