当前位置:网站首页>JS 实现全屏效果
JS 实现全屏效果
2022-07-29 09:35:00 【Sabo】
http://mpvideo.qpic.cn/0b78biabsaaadaacplu7bvqfacwddefaagia.f10002.mp4?
点击按钮触发 requestFullscreen() 函数打开全屏
requestFullscreen () {
const docElm = document.documentElement
if (docElm.requestFullscreen) {
docElm.requestFullscreen()
} else if (docElm.msRequestFullscreen) {
docElm.msRequestFullscreen()
} else if (docElm.mozRequestFullScreen) {
docElm.mozRequestFullScreen()
} else if (docElm.webkitRequestFullScreen) {
docElm.webkitRequestFullScreen()
}
}
点击按钮触发 exitFullScreen() 函数关闭全屏
exitFullScreen () {
if (document.exitFullscreen) {
document.exitFullscreen()
} else if (document.msExitFullscreen) {
document.msExitFullscreen()
} else if (document.mozCancelFullScreen) {
document.mozCancelFullScreen()
} else if (document.webkitCancelFullScreen) {
document.webkitCancelFullScreen()
}
}
如果需要监听全屏状态变换,可以监听 fullscreenchange 事件
document.addEventListener('fullscreenchange', () => {
console.log('fullscreenchange')
})
Vue项目实现地址
https://github.com/gywgithub/vue-d3-examples
https://github.com/gywgithub/vue-d3-examples/blob/master/src/views/Examples.vue#L263
参考链接
https://developer.mozilla.org/en-US/docs/Web/API/Fullscreen_API
https://developer.mozilla.org/en-US/docs/Web/API/Fullscreen_API/Guide
边栏推荐
- AxureRP原型设计 快速开始
- Redis command [gradually improved]
- STM32 application development practice tutorial: getting to know STM32 for the first time
- How does alternates achieve high-performance publish and subscribe?
- C# 值类型和引用类型讲解
- Will the modified data be updated when it is the same as the original data?
- redis命令[逐渐完善]
- Custom configuration
- mysql怎么换成中文
- Using logistic regression and neural network to deal with complex binary classification problems
猜你喜欢

用户身份标识与账号体系实践

远程连接windows版本服务器redis的配置文件设置

In simple terms, dependency injection and its application in Tiktok live broadcast

Explanation of C value type and reference type

Unity Xchart3.0基本用法快速上手

MySQL事务与MVCC如何实现的隔离级别

36. JS动画

No swagger, what do I use?

Nucleic acid scanning code registration experience (how to improve the correct character recognition rate of OCR)

《UnityShader入门精要》总结(2):初级篇
随机推荐
[unity entry program] collection of common learning websites
Flutter文本编辑器
vector实现
User identity identification and account system practice
23 postgraduate entrance examination people hold on! The first wave of exam abandonment peak has arrived!
【云驻共创】【HCSD大咖直播】亲授大厂面试秘诀
工业测控设备内生信息安全技术研究综述
C语言的传参方式(int x)(int *x)(int &x)
[centralized training] hcip cloud computing resource exchange post
【机器学习】朴素贝叶斯代码练习
Gao Zhiwei: data management enables the digital transformation of the transportation industry
使用cpolar发布树莓派网页(cpolar隧道的完善)
How to change MySQL into Chinese
How to realize the isolation level between MySQL transactions and mvcc
Retinal Vessel Segmentation via a Semantics and Multi-Scale Aggregation Network
pytest+allure生成测试报告
系统架构师学习
上海交大牵手淘宝成立媒体计算实验室:推动视频超分等关键技术发展
云原生管理实践:业务引领的DevOps持续交付体系
乱打日志的男孩运气怎么样我不知道,加班肯定很多