$(document).ready(function() { // Your code here console.log("log.js is loaded and ready."); $('#logoutbtn').on('click', function() { // Clear session storage on logout fetch('/logout').then(() => { window.location.href = '/login.html'; }); }); }); $(window).on('beforeunload', function() { console.log("User is leaving log.html"); // Your cleanup code here });