
문서를 언로드할 준비가 되면 onbeforeunload 이벤트 속성이 트리거됩니다.
예
다음 코드를 실행하여 onbeforeunload 속성 −
1 2 3 4 5 6 7 8 9 10 11 | <!DOCTYPE html>
<html>
<body onbeforeunload = "return display()" >
<p>Close this window or press F5.</p>
<script>
function display() {
return "Wanna stay here or leave?" ;
}
</script>
</body>
</html>
|
로그인 후 복사
을 달성할 수 있습니다.
위 내용은 HTML 문서가 언로드되려고 할 때 스크립트를 실행하시겠습니까?의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!