Reputation: 1283
I'm new to HTML so maybe this is easy/simple to answer. I'm trying to popup a youtube video to full screen when the user clicks on a button on my html script. I'm familiar with the youtube player API and javascript but I'm not sure how to make this happen through HTML (I've done it with iOS). Any advice on how to implement this? Thanks!
Upvotes: 0
Views: 1410
Reputation: 766
You need to create code like this
<a href="#" id="fix-fullscreen">Full screen</a>
and create <script>
with javascript
var fullscreen = document.getElementById('fix-fullscreen'),
player = document.getElementById('player');
fullscreen.addEventListener('click', function (e) {
if (~player.src.indexOf('?')) player.src += '&autoplay=1';
else player.src += '?autoplay=1';
var req = player.requestFullscreen
|| player.webkitRequestFullscreen
|| player.mozRequestFullScreen
|| player.msRequestFullscreen;
req.call(player);
e.preventDefault();
});
Hope it help.
Upvotes: 1