欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

html實(shí)現(xiàn)iframe全屏的示例代碼

  發(fā)布時(shí)間:2023-09-01 16:13:16   作者:慕云楓   我要評(píng)論
iframe是HTML5標(biāo)準(zhǔn)中提供的一種新標(biāo)簽,本文就介紹了html實(shí)現(xiàn)iframe全屏的示例代碼,具有一定的參考價(jià)值,感興趣的可以了解一下

前言

html瀏覽器全屏操作,基于jquery
iframe全屏、指定標(biāo)簽全屏

實(shí)現(xiàn)

css

/** 全屏*/
.lay-dbclick-box{
	position: relative;
	width: 100%;
    height: 100%;
}
.lay-dbclick-screen{
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
    height: 100%;
    z-index: 99999999999999;
}
.lay-fullScreen{
	position: fixed;
    left: 0;
    top: 0;
    border-radius: 0;
    padding: 0;
    margin: 0;
    width: 100%;
    height: 100%;
    z-index: 9999999999999;
}

html
關(guān)鍵是lay-dbclick-box和lay-dbclick-screen,其中的iframe是內(nèi)容

<div class="lay-dbclick-box">
	<iframe src="" width="100%" height="100%" id="fullb" frameborder="0" allowfullscreen="" ></iframe>
	<div class="lay-dbclick-screen"></div>
</div>

js

openFullScreen();
/**
 * -------------------------------------------------------------------------------------------------------
 * 通用全屏操作
 */
function openFullScreen(){
	// 雙擊全屏/退出全屏
	$(".lay-dbclick-screen").dblclick(function(){
		var val = $(this).parent().attr("lay-svalue");
		if(!val){
			$(this).parent().addClass("lay-fullScreen");
			$(this).parent().attr("lay-svalue", 1);
			fullScreen();
		}else{
			$(this).parent().removeClass("lay-fullScreen");
			$(this).parent().attr("lay-svalue", "");
			exitFullscreen();
		}
	})
	// 全屏事件監(jiān)聽(tīng)
	document.addEventListener("fullscreenchange", function(){
        if (getFullscreenElement() == null) {
        	console.log("-----------------[退出全屏]--------------")
           $(".lay-fullScreen").attr("lay-svalue", "");
			$(".lay-fullScreen").removeClass("lay-fullScreen");
			exitFullscreen();
        }else {
            console.log("-----------------[打開(kāi)全屏]--------------")
        }
    })
}
/**
 * -------------------------------------------------------------------------------------------------------
 * 獲取全屏狀態(tài)
 */
function getFullscreenElement(){
    return (
        document['fullscreenElement'] ||
        document['mozFullScreenElement'] ||
        document['msFullScreenElement'] ||
        document['webkitFullscreenElement'] || null
    );
}
/**
 * -------------------------------------------------------------------------------------------------------
 * 全屏
 */
function fullScreen() {
    var element = document.documentElement;
    if (element.requestFullscreen) {
        element.requestFullscreen();
    } else if (element.msRequestFullscreen) {
        element.msRequestFullscreen();
    } else if (element.mozRequestFullScreen) {
        element.mozRequestFullScreen();
    } 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();
    }
}

到此這篇關(guān)于html實(shí)現(xiàn)iframe全屏的示例代碼的文章就介紹到這了,更多相關(guān)html實(shí)現(xiàn)iframe全屏內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持腳本之家!

相關(guān)文章

最新評(píng)論