利用浏览器全屏api实现js全屏 |
本文标签:浏览器全屏,js全屏 复制代码 代码如下: (function () { var fullScreenApi = { supportsFullScreen : false, isFullScreen : function () { return false; }, requestFullScreen : function () {}, cancelFullScreen : function () {}, fullScreenEventName : , prefix : }, browserPrefixes = webkit moz o ms khtml.split( ); // check for native support if (typeof document[fullScreenApi.prefix + CancelFullScreen] != undefined) { break; // update methods to do something useful fullScreenApi.isFullScreen = function () { // jQuery plugin return this.each(function () { // export api $(function(){ if (!fullScreenApi.supportsFullScreen) { 复制代码 代码如下: <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>javascript启用全屏</title> <script id="jquery_183" type="text/javascript" class="library" src=jquery-1.8.3.min.js"></script> </head> <body> <button id="fullScreenBtn">点击我进入全屏模式</button> <div id="fullScreen" class="fullScreen"> <h1> 我是全屏区域的内容! </h1> <div id="tip" style="display:none;"> </div> </div> </body> </html> 复制代码 代码如下: body{ background:#fff; } button{ border:1px solid #ccc; cursor:pointer; display:block; margin:auto; position:relative; top:100px; } .fullScreen{ /* Mozilla proposal (dash) */ /* W3C proposal (no dash) */ /* currently working vendor prefixes */ |