标签:style http io ar os 使用 sp java strong
首先来说,这个标题具有误导性,但这样设置改标题也是主要因为video使用的比较多
在html5中,全屏方法可以适用于很多html 元素,不仅仅是video
<!doctype html> <html> <head> <meta charset="utf-8" /> <title>全屏问题</title> <meta http-equiv="content-type" content="text/html; charset=utf-8"/> <meta http-equiv="imagetoolbar" content="no"/> <meta name="apple-mobile-web-app-capable" content="yes"/> <meta http-equiv="X-UA-Compatible" content="IE=Edge"> <style type="text/css"> *{ padding: 0px; margin: 0px; } body div.videobox{ width: 400px; height: 320px; margin: 100px auto; } </style> </head> <body> <div class="videobox"> <video width="400px" height="300px" controls="controls" preload="preload" id="video" poster="poster.jpg"> <source src="./movie.ogg" type="video/ogg" /> <source src="./movie.mp4" type="video/mp4" /> <source src="./movie.webm" type="video/webm" /> <object data="./movie.mp4" width="400px" height="300px"> <embed width="400px" height="300px" src="./movie.swf" /> </object> </video> <button id="fullScreenBtn">全屏</button> </div> <script type="text/javascript"> //alert(document.createDocumentFragment); function launchFullscreen(element) { if(element.requestFullscreen) { element.requestFullscreen(); } else if(element.mozRequestFullScreen) { element.mozRequestFullScreen(); } else if(element.msRequestFullscreen){ element.msRequestFullscreen(); } else if(element.webkitRequestFullscreen) { element.webkitRequestFullScreen(); } } function exitFullscreen() { if (document.exitFullscreen) { document.exitFullscreen(); } else if (document.msExitFullscreen) { document.msExitFullscreen(); } else if (document.mozCancelFullScreen) { document.mozCancelFullScreen(); } else if (document.webkitExitFullscreen) { document.webkitExitFullscreen(); } } document.querySelector(‘#fullScreenBtn‘).onclick = function() { window.setTimeout(function enter(){ launchFullscreen(document.querySelector(‘#video‘)); }); window.setTimeout(function exit(){ exitFullscreen(); },5*1000); }; </script> </body> </html>
标签:style http io ar os 使用 sp java strong
原文地址:http://my.oschina.net/ososchina/blog/349660