pc 크롬에서 풀스크린 원버튼 명령어 > 그누보드5 팁자료실

그누보드5 팁자료실

pc 크롬에서 풀스크린 원버튼 명령어 정보

pc 크롬에서 풀스크린 원버튼 명령어

본문

 


document.fullscreenElement ? document.exitFullscreen() : 엘레먼트ID.requestFullscreen();

 

예제

 


<div id="g5" style="width:500px;margin:0 auto">
    <img style="width:100%" src="https://blog.kakaocdn.net/dn/dGvqOG/btrcONHUaWw/cvKSoMdobz8gmS3ubZTYcK/img.jpg">
    <span style="position:absolute;top:20px;left:20px;cursor:pointer" onclick="document.fullscreenElement?document.exitFullscreen():g5.requestFullscreen()">클릭</span>
</div>

 

이런 건 여러번을 사용할 경우 "함수"를 만드는 것이 편합니다.

 


<script>
function fsMode(fs) {
    document.fullscreenElement ? document.exitFullscreen() : fs.requestFullscreen();
}
</script>
<div id="g5" style="width:500px;margin:0 auto">
    <img style="width:100%" src="https://blog.kakaocdn.net/dn/dGvqOG/btrcONHUaWw/cvKSoMdobz8gmS3ubZTYcK/img.jpg">
    <span style="position:absolute;top:20px;left:20px;cursor:pointer" onclick="fsMode(g5)">클릭</span>
</div>

 

결과물은 https://wittazzurri.com/editor/html_editor.php 에서 확인해 보세요.

사파리나 파폭은 사용 안해서 잘 모르고 관심도 없음.ㅜㅠ

추천
7
  • 복사

댓글 6개

© SIRSOFT
현재 페이지 제일 처음으로