html5——多媒体(四)

全屏兼容

box.requestFullscreen();
box.webkitRequestFullScreen();
box.mozRequestFullScreen();
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        .box {
            width: 200px;
            height: 200px;
            background-color: yellow;

        }
    </style>
</head>
<body>
<div class="box"></div>
<script>
    var box = document.querySelector(".box");
    box.onclick = function () {
        if (box.requestFullscreen) {
            box.requestFullscreen();
        }
        else if (box.webkitRequestFullScreen) {
            box.webkitRequestFullScreen();
        } else if (box.mozRequestFullScreen) {
            box.mozRequestFullScreen();
        } else {
            alert("浏览器不支持");
        }
    }
</script>
</body>
</html>
原文地址:https://www.cnblogs.com/wuqiuxue/p/8098502.html