<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>beforeunload 이벤트 사용하기</title> <link rel="stylesheet" href="style_js.css"> </head> <body> <h3>다른 페이지로 이동하시오</h3> <script> window.addEventListener("beforeunload", function (event) { const message = "변경사항이 저장되지 않을 수 있습니다."; event.returnValue = message; return message; }); </script> </body> </html>