Love beautiful code? We do too.
.unload(): Ràng buộc xử lý một sự kiện tới sự kiện javascript unload. .unload() có thể sẽ khác nhau ở các trình duyệt, cần phải kiểm tra phương pháp này trên các trình duyệt trước khi sử dụng.
Sự kiện unload được kích hoạt khi:
Đã được thêm vào từ phiên bản 1.0
.unload(Xử lý)
$('window').unload(function(){...});
Đã được thêm vào từ phiên bản 1.4.3
.unload("Dữ liệu sự kiện",Xử lý)
Html viết:
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Tiêu đề</title>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(window).unload(function(){
alert("Cảm ơn bạn đã xem!");
});
</script>
</head>
<body>
<p>Reload window hoặc tắt window để thấy kết quả.</p>
</body>
</html>
Hiển thị trình duyệt:
Click để xem kết quả.
Hoclaptrinh.vn © 2017
From Coder With
Unpublished comment
Viết câu trả lời