onbeforeunload ইভেন্ট অ্যাট্রিবিউটটি ডকুমেন্ট আনলোড হওয়ার জন্য প্রস্তুত হলে ফায়ার হয়।
উদাহরণ
নিচের কোডটি চালিয়ে onbeforeunload অ্যাট্রিবিউটের ব্যবহার দেখতে পারেন:
<!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>