I'm very new to Javascript. I'm trying to display a text depending on whether the browser supports fullscreen and whether it is already displaying fullscreen or not. At the top of a page I added the code below. However, this doesn't seem to work. It doesn't display anything. Any idea how to to do this differently?
<script type="text/javascript">
document.addEventListener("fullscreenchange", function (event) {
if (document.fullscreenElement) {
document.write("Fullscreen already activated.");
} else {
displayButton();
}
});
function displayButton () {
if (document.fullscreenEnabled) {
document.write("Open Fullscreen here");
} else {
document.write("Fullscreen not supported.");
}
};
</script>