admin管理员组文章数量:1316008
As asked in the title, what's the first event fired when a web page is loaded to the browser? I believe there are events before window.onload
. What are they, and which one is the first fired?
As asked in the title, what's the first event fired when a web page is loaded to the browser? I believe there are events before window.onload
. What are they, and which one is the first fired?
-
1
Is this a trivia question, do you generally want to run some code before
onload
, or do you want to run some code at some specific point beforeonload
? – deceze ♦ Commented Jul 23, 2010 at 3:29 - 2 similar question stackoverflow./questions/282245/… – Aaron Saunders Commented Jul 23, 2010 at 3:50
3 Answers
Reset to default 5If you're looking to invoke an event handler before onload
, DOMContentLoaded
is one event that usually fires before.
document.addEventListener('DOMContentLoaded', functionRef, false);
Don't know if this helps but firebug/IE Dev Tool is really good for watching JS events execute as the page loads. I use that to caputre events and see the order of how they're happening.
This looks to have some of what you're looking for:
[Updated link - link-rot - this is why you copy and paste essential information directly into an answer]
https://web.archive/web/20090131201912/http://dean.edwards.name:80/weblog/2005/02/order-of-events/
本文标签: javascriptWhat39s the first event fired when a web page is loaded to the browserStack Overflow
版权声明:本文标题:javascript - What's the first event fired when a web page is loaded to the browser - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741994159a2409703.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论