用HTML5做全屏的API

用HTML5做全屏的API

支持chrome、欧朋、IE、ff

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
    <img id="img" src="img/01.jpg" alt="">
    <script type="text/javascript">

        img.onclick = function(){

            if(this.webkitRequestFullScreen){

                this.webkitRequestFullScreen();

            }else if(this.mozRequestFullScreen){

                this.mozRequestFullScreen();

            }else if(this.oRequestFullScreen){

                this.oRequestFullScreen();

            }else if(this.msRequestFullScreen){

                this.msRequestFullScreen();

            }else{

                alert('对不起您的浏览器不支持全屏')
            }

        }

    </script>
</body>
</html>

猜你喜欢

转载自blog.csdn.net/Stay_Hungry_Stay/article/details/81228054