LukeHan 의 잡다한 기술 블로그

자바스크립트로 Fullscreen 적용하기 본문

개발/javascript

자바스크립트로 Fullscreen 적용하기

LukeHan1128 2020. 11. 15. 05:51
반응형

 

var fsCheck = false;

function goFullscreen(data){
	var fullscreenTarget = document.getElementById('page-top');
	if (fsCheck) {
    	if(document.exitFullscreen) {
        	document.exitFullscreen();
		} else if(document.webkitExitFullscreen) {
        	document.webkitExitFullscreen();
		} else if(document.mozCancelFullScreen) {
			document.mozCancelFullScreen();
		} else if(document.msExitFullscreen) {
			document.msExitFullscreen();
		}
        
        $(data).attr('class', $(data).attr('class').replace('-exit', ''));
		fsCheck = false;
	} else {
		if (fullscreenTarget.requestFullscreen) {
			fullscreenTarget.requestFullscreen();
		} else if (fullscreenTarget.webkitRequestFullScreen) {
			fullscreenTarget.webkitRequestFullScreen();
		} else if (fullscreenTarget.mozRequestFullScreen) {
			fullscreenTarget.mozRequestFullScreen();
		} else if (fullscreenTarget.msRequestFullscreen) {
			fullscreenTarget.msRequestFullscreen();
		}

		$(data).attr('class', $(data).attr('class').replace('md-fullscreen', 'md-fullscreen-exit'));
		fsCheck = true;
	}
}

 

 

반응형
Comments