什么是DOM ready事件? [英] What is the DOM ready event?

查看:272
本文介绍了什么是DOM ready事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在收到页面内容(整个HTML元素)后立即触发脚本,但不必渲染它。

I need to fire a script as soon as the page content (the whole HTML element) has been received, but it doesn't have to be rendered yet.

我假设只有一个简单的< script> 标签,它在我的顶部执行一些代码页面应该做的伎俩?

I assume that just having a simple <script> tag that executes some code at the very top of my page should do the trick?

以不同方式表达问题:DOM准备好是否已将所有元素和资源拉并呈现

To formulate the question differently: does DOM ready mean that all elements and resources have been pulled and rendered?

推荐答案

DOM就绪意味着浏览器已经接收并解析了所有HTML,现在可以对其进行操作。

DOM ready means that all the HTML has been received and parsed by the browser into the DOM tree which can now be manipulated.

在页面完全呈现之前发生(因为外部资源可能尚未完全下载 - 包括图像,CSS,JavaScript和任何其他链接资源)。

It occurs before the page has been fully rendered (as external resources may have not yet fully downloaded - including images, CSS, JavaScript and any other linked resources).

实际事件名为 DOMContentLoaded

这篇关于什么是DOM ready事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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