언로드 이벤트는 페이지를 언로드(또는 새로 고침)할 때 트리거됩니다. 다음 코드를 실행하여 onunload를 구현하는 방법을 배울 수 있습니다. 자바스크립트의 이벤트
예시
<!DOCTYPE html>
<html>
<body onunload="newFunc()">
<p>Close the page and see what happens!</p>
<p>This event may give unexpected results.</p>
<script>
function newFunc() {
alert("Thank you!");
}
</script>
</body>
</html>