Fullscreen button for your embedded games

2017-06-11 20:42:40 | By iDev | idevgames.co.uk
Share:

If you want to add a fullscreen button when embedding a game onto your site just use the code below. This javascript button will work on any iframe so you could edit the onclick="goFullscreen('embededGame'); by editing the 'embededGame' to the id of your iframe. 

 

Add the below HTML button and Javascript on the same page as the embedded game:

HTML
 
<button onclick="goFullscreen('embededGame'); return false">Fullscreen</button>
 
<script>
function goFullscreen(id) {
    var element = document.getElementById(id);
    if (element.mozRequestFullScreen) {
      element.mozRequestFullScreen();
    } else if (element.webkitRequestFullScreen) {
      element.webkitRequestFullScreen();
    }
}
</script>

0 Login to like

Comments

Would you like to comment on this post? Create a free account in less than 1 minute.

Back to top

7W0-70N3 V4L3N71N3 Bump Reminder DISBOARD Dyno Future GameAddict
9 Online Discord
·