0

I want to incorporate a fullscreen function (with button) in a videoplayer i'm making with javascript. This is my code:

HTML:

<div id="buttonbar" style="display: none;")>
<button id="fullscreen" title="Full screen">[oO]</button>

This creates the button for the fullscreen functon. Now in my .js I have got the following code:

var fullscreen = function() {
'use strict';
if (video.requestFullscreen) {
video.requestFullscreen();
} else if (video.webkitRequestFullscreen) {
video.webkitRequestFullscreen();

document.getElementById("fullscreen").addEventListener("click", function () {
video.requestFullscreen();
alert("goes to fullscreen");
}, false);

Somehow the button doesn't respond when you click the button, but I just can't figure out why. How can I fix this?

4

0 回答 0