当前位置:网站首页>Common events of window objects
Common events of window objects
2022-07-27 03:13:00 【Hugging spinner】
One . Window page load event

window.onload It's the window ( page ) Loading event , This event is triggered when the document content is fully loaded ( Include images 、 Script files 、CSS Documents, etc. ), Just call the handler .
Be careful ∶
1. With window.onload You can put the JS The code is written to the top of the page element , because onload Yes, wait until all the page contents are loaded , Then execute the processing function .
2. window.onload The traditional method of registering events can only be written once , If there are more than one , I'll take the last window.onload Subject to .
3. If you use addEventListener There is no limit 
DOMContentLoaded Event triggered , Only when the DOM Loading complete , Don't include style sheets , picture ,flash wait .le9 The above supports
If there are many pictures on the page , From user access to onload Triggering may take a long time, and the interaction effect cannot be realized , It's bound to affect the user experience , Use at this time DOMContentLoaded Events are more appropriate .
load Wait until all the page contents are loaded , Include page dom Elements , picture ,f1ash, css wait
DOMContentLoaded yes DOM Loading finished , No pictures falsh css You can execute it later , Loading speed ratio load Faster

Two . Window resizing Events

window.onresize Is to adjust the window size to load events , Handler function called when triggered .
Be careful ∶
1. As long as the window size changes in pixels , Will trigger this event .
⒉ We often use this event to do responsive layout .window.innerWidth The width of the current screen

边栏推荐
- AcWing 2074. 倒计数 模拟
- CAS部署使用以及登录成功跳转地址
- 红宝书第四版的一个错误?
- 抖音服务器带宽有多大,才能供上亿人同时刷?
- CAS deployment and successful login jump address
- day6
- Non global function of lua function
- ansible系列之:不收集主机信息 gather_facts: False
- [binary search simple question] leetcode 35. search insertion position, 69. Square root of X, 367. Effective complete square, 441. Arrange coins
- Functions that should be selected for URL encoding and decoding
猜你喜欢

How big is the bandwidth of the Tiktok server for hundreds of millions of people to brush at the same time?

vs2019 中编译和使用 protobuf 库

The EXE compiled by QT is started with administrator privileges

Okaleido tiger is about to log in to binance NFT in the second round, which has aroused heated discussion in the community

185. 部门工资前三高的所有员工(必会)

红宝书第四版的一个错误?

身家破亿!86版「红孩儿」拒绝出道成学霸,已是中科院博士,名下52家公司

Non global function of lua function

百度云人脸识别

从ACL 2022 Onsite经历看NLP热点
随机推荐
Role of thread.sleep (0)
2513: 小勇学分数(公约数问题)
身家破亿!86版「红孩儿」拒绝出道成学霸,已是中科院博士,名下52家公司
一道数学题,让芯片巨头亏了5亿美金!
{“errcode“:44001,“errmsg“:“empty media data, hint: [1655962096234893527769663], from ip: 222.72.xxx.
ArduinoUNO驱动RGB模块全彩效果示例
Functions that should be selected for URL encoding and decoding
Arduino UNO +74hc164 water lamp example
Play a parallel multithreaded mcu-mc3172
Make ppt timeline
从ACL 2022 Onsite经历看NLP热点
Knowledge points of test questions related to software testing
机器学习【Matplotlib】
Analysis of [paper] pointlanenet papers
[binary search simple question] leetcode 35. search insertion position, 69. Square root of X, 367. Effective complete square, 441. Arrange coins
Zhang Ping, Alibaba cloud Solution Architect: system construction of cloud native digital safety production
Debezium series: the binlog file cannot be recovered after the record is hung from the library server, and the task is switched to the main library to ensure that the data is not lost
Call jshaman's Web API interface to realize JS code encryption.
HCIP第十四天笔记
周全的照护 解析LYRIQ锐歌电池安全设计