Can the webNavigation API be used to accomplish what the following code does in a web page that does not have added permissions, but allow for a custom message?
window.addEventListener(“beforeunload”, function (event) {
event.returnValue = “\o/”;
return “\o/”;
});
I can listen for the events in the background script but don’t understand how the event in the page can be stopped/delayed until the user clicks again.
For example, is it possible to listen in the background script for a tab close event and then stop the tab from closing until the user reads a custom message warning that they may lose data if they don’t save it before closing the tab, and then resume the close if the user chooses to do so, or stop it if user chooses to cancel?
Thank you.