时间:2021-05-25
复制代码 代码如下:
(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;
}
.fullScreen:full-screen {
width:100%;
height:100%;
}
.fullScreen:fullscreen {
width:100%;
height:100%;
}
.fullScreen:-webkit-full-screen, .fullScreen:-moz-full-screen {
width:100%;
height:100%;
}
:-webkit-full-screen{
width:100%;
height:100%;
}
声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。
JS全屏和退出全屏js实现浏览器窗口全屏和退出全屏的功能,市面上主流浏览器如:谷歌、火狐、360等都是兼容的,不过IE低版本有点瑕疵(全屏状态下仍有底部的状态栏
复制代码代码如下://设置浏览器全屏functionf_SetFullScreen(){//如果浏览器不是全屏则将其设置为全屏模式if(!f_IsFullScr
本文实例讲述了Android开发实现浏览器全屏显示功能。分享给大家供大家参考,具体如下:业务需求:浏览器设置中支持全屏显示的功能。分析:只需要在设置界面上增加是
本文实例为大家分享了vue全屏事件开发的具体代码,供大家参考,具体内容如下在项目中有需求相应浏览器全屏,写了个案例代码先看看效果吧全屏显示:html代码:js代
百度浏览器全屏显示的方法如下: 1、打开百度浏览器,点击右上方三条杠图标的菜单按钮; 2、然后点击缩放后面的全屏按钮,便可全屏浏览; 3、当然通过快捷键f