
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Usage of the onbeforeunload Event in JavaScript
If you want to trigger an event before the document is loaded, then use the onbeforeunload event.
Example
You can try to run the following code to learn how to implement onbeforeunload event in JavaScript.
<!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>
Advertisements