2

I wanted to allow users to click a link to make my webpage entirely full screen, using the RequestFullScreen function that browsers are deploying. You can see the page here. As suggested here, I'm calling requestFullScreen method of document.documentElement. The code looks like this:

var el = document.documentElement
    , rfs = el.requestFullScreen
         || el.webkitRequestFullScreen
         || el.mozRequestFullScreen
         || el.msRequestFullScreen
;
if(typeof rfs!="undefined" && rfs){
  rfs.call(el);
}

The thing is, I get really strange artifacts doing this, in my case the background is mostly black (you can see if you click the link). Am I doing something wrong? Manually setting fullscreen in the browser works just fine in all the browsers I've tested, which made me think maybe documentElement is somehow not inclusive enough.

In other words:

it seems like document.documentElement.mozRequestFullScreen doesn't do the same thing as the user manually setting fullscreen. What's the difference? Why is this difference causing problems?

Community
  • 1
  • 1
John McDonnell
  • 1,360
  • 2
  • 17
  • 18

2 Answers2

1

Got this done with this function.

// Launch full screen
function launchFullscreen(element) {
  if(element.requestFullscreen) {
    element.requestFullscreen();
  } else if(element.mozRequestFullScreen) {
    element.mozRequestFullScreen();
  } else if(element.webkitRequestFullscreen) {
    element.webkitRequestFullscreen();
  } else if(element.msRequestFullscreen) {
    element.msRequestFullscreen();
  }
}

Full article

nznoor
  • 2,854
  • 1
  • 19
  • 29
1

I've checked the site and confused, code seems fine but you may try this http://johndyer.name/native-fullscreen-javascript-api-plus-jquery-plugin/

The Alpha
  • 131,979
  • 25
  • 271
  • 286
  • Hi, thanks, i saw that but didn't use it because it looks like it would end up doing the exact same thing as my current code, at least on Firefox and Chrome, but I'll give it a try anyway. – John McDonnell Jan 25 '12 at 05:02
  • Tried it. As I suspected, it didn't help. Interestingly I $(window).requestFullScreen and $(document).requestFullScreen both showed the same weird effect. – John McDonnell Jan 25 '12 at 05:45