首頁 >web前端 >js教程 >利用瀏覽器全螢幕api實作js全螢幕_jquery

利用瀏覽器全螢幕api實作js全螢幕_jquery

WBOY
WBOY原創
2016-05-16 17:03:42944瀏覽

複製程式碼程式碼如下:

(function () {


(function () {
  supportsFullScreen : false,
  isFullScreen : function () {
   return false;
  }, : function () {},
  fullScreenEventName : '',
  前綴: ''
 },
 browserPrefixes = 'webkit moz o ms khtml'.split(' ');;

;
;
;
;
;
;
;

 // 檢視本機支援
 if (typeof document.cancelFullScreen != 'undefined') {

  fullScreenApi.supportsFullScreen = truecm;字首

  for (var i = 0, il = browserPrefixes.length; i    fullScreenApi.prefix = browserPrefixes[i];
;
;

;

;
;
;

;

;
;
   if (typeof document[fullScreenApi.prefix 'CancelFullScreen'] != 'undefined') {
    fullScreenApi.supportsFullScreen = true;    休息;
   }
  }
 }

 // 更新方法來執行一些有用的操作
 if (fullScreenApi.supportsFullScreen) {
  fullScreenApi.fullScreenEventName = fullScreenApi.prefix 'fulcreen];
  fullScreenApi.isFullScreen = function () {
   switch (this.prefix) {
   case '':   預設值:
    return document[this.prefix 'FullScreen'];

   }   return (this.prefix = == '') ? el.requestFullScreen() : el[this.prefix 'RequestFullScreen']();

  }
  fullScreenApi.cancelFullScreen = function (>  fullScreenApi.cancelFullScreen = function (>  fullScreenApi.cancelFullScreen = function (H>  fullScreenApi.cancelFullScreen = function ( == '') ? document.cancelFullScreen() : document[this.prefix 'CancelFullScreen']();
  }

 }


 // jQuery 外掛程式
 if (typeof jQuery != 'undefined') {
  jQuery.fn.requestFullScreen = function () {

   return this.each(function () {
    if (fullScreenApi.supportsFullScreen) {

    ;

  };
}

 // 匯出 api

 window.fullScreenApi = fullScreenApi;
})();

$(function(){
 $("#fullScreenBtn").click(function(){
  $("#fullScreen").requestFullScreen();
 });
 if(window.top != self){
  $("#tip").text("iframe裡面不能示範功能!請點選右下角的全螢幕查看!").show();

 }

});

if (!fullScreenApi.supportsFullScreen) {
 alert("您的破瀏覽器不支援全螢幕API哦,請換高版本的chrome或firebox!");

}

複製程式碼
程式碼如下:






;
 
  
  javascript全螢幕<br><br> <script id="jquery_183" type="text/javascript" class="library" src="jquery-1.8.3.min.js%22"></script><br> <br> 
  
  

   的內容! /body>



複製程式碼程式碼如下:

主體{
背景:#fff;
}
按鈕{
 邊框:1px 實心#ccc;
 遊標:指針;
  邊距:自動;
  位置:相對;
  頂部:100px;
}
.fullScreen{

 padding-top:10%;
 text-align:center;
 背景:無重複捲動 0 0 #FFFFFF;
}

/* Mozilla 提案(破折號)*/

.fullScreen:全螢幕 {
    寬度:100%;
    高度:100%;
}
    高度:100%;

}


/* W3C 提案(無破折號)*/
.fullScreen:fullscreen {
    寬度:100%;
    高度:100%;

}


/* 目前有效的供應商前綴*/
.fullScreen:-webkit-full-screen, .fullScreen:-moz-full-screen {
    %;
}
:-webkit-全螢幕{
寬度:100%;
    高度:100%;
}

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn