问题
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.
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();
}
});
It passes the support test (Chrome 28) but nothing happens. What am I missing?
回答1:
It would seem, after further research, that the fullscreen API can only be activated via user interaction for security reasons. If anyone knows otherwise, please feel free to post.
回答2:
I use a trick...
I listen for any click on the body to activate.
Eg:
$('body').on('click', '*', function() {
screenfull.request();
});
N.B.: It does not track buttons (e.t.c) that already have event handlers...
来源:https://stackoverflow.com/questions/15890928/jquery-open-request-fullscreen-browser-on-load