简体   繁体   English

在页面加载时,如何使浏览器全屏显示?

[英]On page load, how can I make my browser full screen?

I have a page with a div #container which I would like to have go into full screen mode (or at least request to go into full screen mode) on supported browsers. 我有一个包含div #container的页面,我希望在支持的浏览器上进入全屏模式(或至少要求进入全屏模式)。

I downloaded this plugin and although the example all show using a button to enter fullscreen, I'd like to do it on load. 我下载了此插件,尽管示例全部使用一个按钮进入全屏显示,但我希望在加载时进行操作。

I tried: 我试过了:

$(window).load(function() { if($.support.fullscreen){ $('#container').fullScreen(); } });

You can do this sort of using a popup and window.open , or center it then make it H/W proportionate to the screen size. 你可以做这种使用弹出 window.open ,或中心则使其H / W比例的屏幕尺寸。 But it is a very bad idea (of course subject to popup blocking), and could be considered malicious behavior by some users. 但这是一个非常糟糕的主意(当然会受到弹出窗口阻止),某些用户可能会将其视为恶意行为。 Full screen should be a choice, not a default option as there is little legitimate reason to go that route unless you offer the user at least the chance to save a setting to accept this behavior on subsequent visits. 全屏显示应该是一个选择,而不是默认选项,因为没有什么合理的理由走这条路,除非您为用户提供至少一个保存设置以在以后的访问中接受此行为的机会。 Otherwise there are tricks to get it from the main page, google can lead you that route should you decide to do it, I however still suggest highly against it. 否则,有一些技巧可以从主页上获取它,如果您决定这样做,谷歌可以引导您使用该路线,但是我仍然强烈反对。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM