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개