Use the addEventListener() method to attach a "beforeunload" event to the window object.
Close this window, press F5 or click on the link below to invoke the beforeunload event.