Fullscreen toggle does not work inside iframe (Kongregate, other portals)

Hello,

I have noticed that the fullscreen toggle does not function in Chrome 42.0.2311.90m and Unity 5.0.1f1 when the game is embedded inside an iframe.

You can test this via this simple html:

<!DOCTYPE html>
<html>
<body>
<iframe src="index.html" width=1000 height=700 />
</body>
</html>

When the game is embedded this way, these methods of going fullscreen seem to have no effect:

  • the fullscreen button below the game
  • Screen.SetResolution(Screen.currentResolution.width, Screen.currentResolution.height, true);
  • Screen.fullScreen = true;

This is problematic since Kongregate and other big portals rely on iframes to embed games into their site. Often the allowed resolution is small, so fullscreen toggle is very useful.

Is there a recommended workaround, or perhaps I am doing something wrong? Thanks in advance for any insights you can provide :slight_smile:

There is some discussion about it here:

But I couldn’t get it to work on kongregate either.

Thanks, but I think that’s a different issue - I am making the call on response to a user button click and so fullscreen WebGL does work for me when the game isn’t embedded in an iframe.

I found that the issue is fixable in my code – the iframe needs to contain special tags to allow fullscreen usage:

<iframe
   src="index.html"
   width=1000
   height=700
   allowfullscreen=true
   webkitallowfullscreen=true
   mozallowfullscreen=true />

Now hopefully we can get the big portal sites to include these new tags… :wink:

10 Likes