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

 

[code]

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

[/code]

 

예제

 

[code]

<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>

[/code]

 

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

 

[code]

<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>

[/code]

 

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

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

|

댓글 6개

좋은 자료 감사합니다.
@푸른산타 감사합니다
감사 합니다.
@들레아빠 감사합니다
공개해 주셔서 감사합니다.
@브러운아이 감사합니다.
댓글을 작성하시려면 로그인이 필요합니다.

그누보드5 팁자료실

+
제목 글쓴이 날짜 조회
3년 전 조회 2,893
3년 전 조회 2,637
3년 전 조회 1,994
3년 전 조회 2,655
3년 전 조회 1,621
3년 전 조회 1,958
3년 전 조회 2,057
3년 전 조회 2,488
3년 전 조회 4,624
3년 전 조회 4,353
3년 전 조회 2,444
3년 전 조회 2,060
3년 전 조회 1,672
3년 전 조회 3,399
3년 전 조회 2,133
3년 전 조회 2,972
3년 전 조회 3,461
3년 전 조회 1,776
3년 전 조회 2,090
3년 전 조회 2,326
3년 전 조회 2,775
3년 전 조회 1,847
3년 전 조회 2,377
3년 전 조회 3,456
3년 전 조회 2,094
3년 전 조회 3,489
3년 전 조회 1,831
3년 전 조회 1,548
3년 전 조회 2,628
3년 전 조회 2,347