文件内的窗口加载准备好了吗? [英] window load inside a document ready?

查看:190
本文介绍了文件内的窗口加载准备好了吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

很抱歉,如果之前已经回答了这个问题,但所有搜索都会讨论这些差异,而不是一起使用这两个差异。

Sorry if this has been answered before but all searches talk about the differences, not about using the two together, if possible.

简单来说,可以 $(window).load。(function(){})使用INSIDE of $(document).ready。(function(){})

Simply, can $(window).load.(function() {}) be used INSIDE of $(document).ready.(function() {}) ?

我有一些事情应该在DOM加载后完成,但后来我想在图像加载完成后才显示某些元素。在Explorer 8中唯一可行的是将 $(window).load 函数放在 $(document).ready 包含其他所有内容。

I have some things that should be done after the DOM is loaded but then I want to reveal certain elements only after the images have finished loading. The only thing that works in Explorer 8, is putting the $(window).load functions inside of the $(document).ready with everything else.

这是可接受的做法吗?

我只是想使用在完全构造完成后,显示包含小图像(如工具栏)的 DIV 的最可接受的方法。 (可见性 隐藏显示 没有,例如)。此 DIV 的HTML由 $(文档).ready 内的代码编写,然后附加到正文在使用 $(窗口).load 之前使用 $('body')。append()

I just want to use the most acceptable method to reveal a DIV that contains small images, like a toolbar, after it's fully constructed. (visibility hidden versus display none, for example). The HTML for this DIV is written by the code inside the $(document).ready and then appended to the body using $('body').append() before using the $(window).load.

我在Explorer 8中遇到很多问题。

I'm having lots of problems with Explorer 8.

推荐答案

这项工作正常很好,是一种可接受的做法。毕竟,如您所述,可能存在 $(window).load()处理程序中的逻辑依赖于DOM准备就绪后的工作。如果窗口实际上已经在您设置 $(窗口).load()时已加载,则处理程序将立即触发。

This works fine and is an acceptable practice. After all, as you describe, there may be cases where the logic in the $(window).load() handler depends on work taking place after the DOM is ready. If the window is in fact already loaded by the time you set up $(window).load(), the handler will just fire immediately.

这篇关于文件内的窗口加载准备好了吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆