full-screen browser window on load document

做~自己de王妃 提交于 2019-12-11 21:54:53

问题


How can I full-screen browser window after loading the page? I have used code like below in jQuery but its working only using the event click; but I want that to be worked on load.

jQuery(document).ready(function($) {
    function fullScreen(){
            var docElm = document.documentElement;
            if (docElm.requestFullscreen) {
                //alert("requestFullscreen");
                docElm.requestFullscreen();
            }
            else if (docElm.mozRequestFullScreen) {
                //alert("mozRequestFullScreen");
                docElm.mozRequestFullScreen();
            }
            else if (docElm.webkitRequestFullScreen) {
                //alert("webkitRequestFullScreen");
                docElm.webkitRequestFullScreen();
            }

    }
});

回答1:


from https://wiki.mozilla.org/Gecko:FullScreenAPI#Suggested_UA_Policy

..requestFullScreen while the window is already in the full-screen state is approved. Otherwise, requestFullScreen outside a user action (e.g. a non-synthesized input event handler) is denied.

so it's not possible force a fullscreen if it's not triggered by a user action



来源:https://stackoverflow.com/questions/19856794/automatic-browser-full-screen-switch-on-document-load-ready

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!