使用 Javascript 以编程方式将 Google Chrome 置于全屏模式?
我最近在使用 YouTube 时,点击了 YouTube 视频中的全屏按钮,屏幕顶部出现一条消息,说我已进入全屏模式。此消息是您在键盘上按 f-11 时收到的本机消息。我还在某处读过一些东西(我现在找不到)说现在可以用 Javascript 来做到这一点。
问题
我如何根据命令将用户浏览器(Google Chrome)置于全屏? - 如果没有扩展,他们需要事先下载或任何类似性质的东西。
我正在使用 jQuery,所以这是最好的,但我根本找不到如何做到这一点。
编辑:我已经看到了这种性质的其他问题,但他们很久以前就被问到了,我相信这个功能是相当新的。
I was on youtube recently when I clicked the fullscreen button by the youtube video and a message appeared at the top of the screen saying that I was put into full-screen mode. This message was the native message you get when pressing f-11 on your keyboard. I also read something somewhere(that I now cannot find) saying that it's now possible to do this with Javascript.
Question
How would I put the users browser(Google Chrome) into fullscreen, on command? - without an extension they would need to download prior, or anything of that nature.
I'm using jQuery so that would be best, but I can't find how to do it at all.
EDIT: I've seen other questions of this nature, but they were asked a long time ago, and I believe this functionality is fairly new.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这是一篇好文章:本机全屏 JavaScript API 。它描述了所有三种方法:webkit、firefox 和 W3-proposal。
Here is good article: Native Fullscreen JavaScript API . It describes all three methods: webkit, firefox and W3-proposal.
尝试这些功能,它们似乎是本机的:
Try these functions, they appear to be native:
API 仍然在不断变化,尤其是自 W3C 本周加入以来。我花了一些时间研究这些差异,以便在 MediaElement.js HTML5 视频播放器中实现全屏,并且它在 Safari 5.1+、Chrome 15+ 或 Firefox Nightly 中运行良好。
The API is still heavily in flux especially since the W3C joined in this week. I spent some time working through the differences to implement Full Screen in MediaElement.js HTML5 video player, and its working great in Safari 5.1+, Chrome 15+, or Firefox Nightly.