ডকুমেন্ট আনলোড হওয়ার আগে ইভেন্ট ট্রিগার করতে হলে onbeforeunload ইভেন্ট ব্যবহার করা হয়।
উদাহরণ
<!DOCTYPE html> <html> <body onbeforeunload="return myFunction()"> <a href="https://www.qries.com">Click to open Qries</a> <script> function myFunction() { return "Working with onbeforeunload event"; } </script> </body> </html>