Html程序  |  26行  |  1.13 KB

<!DOCTYPE html>
<script>
    function enterFullScreen() {
        var element = document.getElementById("fullscreen");
        element.innerText = "Press the space bar.";
        
        var consoleDiv = document.getElementById("console");
        consoleDiv.innerHTML = "<span style='color:red'>FAIL</span>";
        
        document.addEventListener("keydown", function(event) {
            consoleDiv.innerHTML = "<span style='color:green'>PASS</span>";
            document.webkitCancelFullScreen();
        }, true);
        
        element.addEventListener("webkitfullscreenchange", function(event) {
            if (!document.webkitIsFullScreen)
                element.innerText = "";
        }, false);
        
        element.webkitRequestFullScreen();
    }
</script>
<p>This test checks that keyboard events are received by an element in full screen mode. To run the test, press the 'Enter Full Screen' button then press the space bar. The test passes if the element exists full screen and you see the word 'PASS' below.</p>
<button onclick="enterFullScreen()">Enter Full Screen</button>
<div id="fullscreen"></div>
<div id="console"></div>