复制代码 代码如下:
(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.cancelFullScreen != 'undefined') {
fullScreenApi.supportsFullScreen = true;
} else {
// check for fullscreen support by vendor prefix
for (var i = 0, il = browserPrefixes.length; i < il; i++) {
fullScreenApi.prefix = browserPrefixes[i];
if (typeof document[fullScreenApi.prefix + 'CancelFullScreen'] != 'undefined') {
fullScreenApi.supportsFullScreen = true;
break;
}
}
}
// update methods to do something useful
if (fullScreenApi.supportsFullScreen) {
fullScreenApi.fullScreenEventName = fullScreenApi.prefix + 'fullscreenchange';
fullScreenApi.isFullScreen = function () {
switch (this.prefix) {
case '':
return document.fullScreen;
case 'webkit':
return document.webkitIsFullScreen;
default:
return document[this.prefix + 'FullScreen'];
}
}
fullScreenApi.requestFullScreen = function (el) {
return (this.prefix === '') ? el.requestFullScreen() : el[this.prefix + 'RequestFullScreen']();
}
fullScreenApi.cancelFullScreen = function (el) {
return (this.prefix === '') ? document.cancelFullScreen() : document[this.prefix + 'CancelFullScreen']();
}
}
// jQuery plugin
if (typeof jQuery != 'undefined') {
jQuery.fn.requestFullScreen = function () {
return this.each(function () {
if (fullScreenApi.supportsFullScreen) {
fullScreenApi.requestFullScreen(this);
}
});
};
}
// export 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!");
}
复制代码 代码如下:
<!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{
padding-top:10%;
text-align:center;
background: none repeat scroll 0 0 #FFFFFF;
}
/* Mozilla proposal (dash) */
.fullScreen:full-screen {
width:100%;
height:100%;
}
/* W3C proposal (no dash) */
.fullScreen:fullscreen {
width:100%;
height:100%;
}
/* currently working vendor prefixes */
.fullScreen:-webkit-full-screen, .fullScreen:-moz-full-screen {
width:100%;
height:100%;
}
:-webkit-full-screen{
width:100%;
height:100%;
}
浏览器全屏,js全屏
更新动态
- 《忆蚀》Subliminal:揭秘后室之谜,路知行献声Weplay文化展
- 那英《征服NEWXRCD台湾版》日本压制[WAV+CUE]
- 群星《金曲百分百上》3CD(香港版)[WAV+CUE]
- 刘欢《雨中的树(新歌加精选)2CD》德国HD24K金碟[WAV+CUE]
- 郑源 《世间情歌》6N纯银SQCD[WAV+CUE][1G]
- 群星《粤潮2HQII》头版限量编号[低速原抓WAV+CUE][991M]
- 群星《2023好听新歌21》十倍音质 U盘音乐[WAV分轨][1G]
- 《热血传奇》双11感恩回馈 超值狂欢30天
- 原神5.2版本活动汇总 5.2版本活动有哪些
- 张敬轩.2010-NO.ELEVEN【环球】【WAV+CUE】
- 黄丽玲.2006-失恋无罪【艾回】【WAV+CUE】
- 阿达娃.2024-Laluna【W8VES】【FLAC分轨】
- 宝可梦大集结段位等级划分表大全 大集结段位一览
- 龙腾世纪影障守护者工坊与装备如何升级 工坊与装备升级说明
- 龙腾世纪影障守护者全成就攻略分享 龙腾世纪4全成就列表一览