javascript how to tell when page is about to reload w3schools code example Example: refresh window js window.location.reload();