HTML DOM beforeunload 이벤트

1 개요[ | ]

beforeunload 이벤트
이 사이트에서 나가시겠습니까?
<script>
window.addEventListener("beforeunload", function (e) {
  var confirmationMessage = "\o/";
  e.returnValue = confirmationMessage; // Gecko, Trident, Chrome 34+
  return confirmationMessage; // Gecko, WebKit, Chrome <34
});
</script>

2 브라우저 경고창 예시[ | ]

크롬

Chrome - 이 사이트에서 나가시겠습니까.png

3 같이 보기[ | ]

4 참고[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}