全屏幕运行onclick,但不是onload [英] FullScreen works onclick but not onload

查看:100
本文介绍了全屏幕运行onclick,但不是onload的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试此处的代码启动全屏模式。如果执行 onclick ,但不是 onload ,它就会起作用。 (我还发现,如果不立即点击警报,它会在禁用它之前设置一个警报)。也许问题在于有时候浏览器还没有准备好全屏显示。



那么当一个页面完全准备就绪时,最后一个事件会发生什么?或者解决方案不同?

解决方案

全屏需要用户交互才能启动。这是一项安全功能。



想象一下,如果某些弹出窗口可能会强制您进入全屏模式,请锁定您的鼠标指针,并在未经您许可的情况下开始播放广告。 >

在文档'fullscreenchange'事件处理程序中触发具有可见性的'启用全屏'链接或按钮似乎是一种切实可行的方法。


I'm trying the code from here to start fullscreen mode. It works if executed onclick , but not onload. (I've also discovered that setting an alert before it will disable it unless the alert is clicked immediately.) So perhaps the problem is that sometimes the browser isn’t 'ready' for fullscreen.

So what is the last event fired when a page is completely ready? Or is the solution different?

解决方案

Fullscreen requires user interaction to initiate. It's a security feature.

Imagine if some pop-up could force you into fullscreen mode, lock your mouse pointer, and start playing an advertisement without your permission.

Having a 'enable full screen' link or button who's visibility is toggled in the document 'fullscreenchange' event handler seems like a practical approach.

这篇关于全屏幕运行onclick,但不是onload的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆