开发者

Event which triggers before DOMContentLoaded

开发者 https://www.devze.com 2023-04-12 09:32 出处:网络
In my Firefox extension I am using DOMContentLoaded to detect page load and insert my HTML. Is the开发者_StackOverflow中文版re an event which triggers before this and still the document is available a

In my Firefox extension I am using DOMContentLoaded to detect page load and insert my HTML. Is the开发者_StackOverflow中文版re an event which triggers before this and still the document is available at that time?


Note: This answer refers to XUL-based extensions. As of Firefox 57, this technology is obsolete. The functionality mentioned here is no longer available to extensions.

There is content-document-global-created notification that is sent out when a document is created, before any content is added to it (to be precise, it happens when the browser receives the HTTP headers of the response and knows that it isn't a redirect or such). That's the earliest point where you can get the document. The DOMContentLoaded event is fired once Gecko finishes downloading the contents of the document, that's the earlies point where you can access the complete DOM. In between there is a bunch of other events, e.g. lots of progress listener events - which one you use depends on what you are trying to do, there is no general answer.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号