当前位置:网站首页>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

边栏推荐
- Portraiture5全新升级版磨皮滤镜插件神器
- 数据库红的表如何设计才能使性能更加优化
- ArduinoUNO驱动RGB模块全彩效果示例
- The most complete basic knowledge of software testing in the whole network (a must for beginners)
- [dynamic programming simple question] leetcode 53. maximum subarray and
- Complete source code of mall applet project (wechat applet)
- 红宝书第四版的一个错误?
- 八皇后编程实现
- Role of thread.sleep (0)
- Go to export excel form
猜你喜欢

LabVIEW中编程更改进程的优先级

抖音服务器带宽有多大,才能供上亿人同时刷?

OpenTelemetry 在服务网格架构下的最佳实践

win10/win11无损扩大C盘空间,跨盘合并C、E盘

单例模式(双检锁)

How to use devaxpress WPF to create the first MVVM application in winui?

Kubeadmin到底做了什么?

ArduinoUNO驱动RGB模块全彩效果示例

HCIP第十三天笔记

Use the most primitive method to manually implement the common 20 array methods
随机推荐
百度云人脸识别
易灵思T35 FPGA驱动LVDS显示屏
The most complete basic knowledge of software testing in the whole network (a must for beginners)
我的爬虫笔记(七) 通过爬虫实现blog访问量+1
Compile and use protobuf Library in vs2019
[SQL简单题] LeetCode 627. 变更性别
IDEA 连接数据库查询数据后控制台表头中文乱码的解决方法
Cuteone: a onedrive multi network disk mounting program / with member / synchronization and other functions
Kubeadmin到底做了什么?
setTimeout第一个参数应该注意的地方
八皇后编程实现
Attention should be paid to the first parameter of setTimeout
仿知乎论坛社区社交微信小程序
OD-Paper【3】:Faster R-CNN: Towards Real-Time Object Detection with Region Proposal Networks
Kubernetes Dashboard 部署应用以及访问
1.28亿美元!芬兰量子计算公司IQM获世界基金支持
在线问题反馈模块实战(十五):实现在线更新反馈状态功能
素因子分解--C(gcc)--PTA
[二分查找简单题] LeetCode 35. 搜索插入位置,69. x 的平方根,367. 有效的完全平方数,441. 排列硬币
Alibaba cloud technology expert Yang Zeqiang: Construction of observability on elastic computing cloud