I am trying to update the DB when a user closes/reloads the page. I have tried all sort of combinations with "onunload", "onbeforeunload", and "onhide" but nothing works.
Here's the code I would like to run when the page is closed:
function saveCurrentOutline () {
db.get(document.getElementById("selectedTab").dataset.id).then(function(doc) {
doc.resume = document.getElementById("outlineSelected").dataset.id
return db.put(doc);
});
}
Any suggestion as to how I can accomplish that?
*Edit: I am trying to run it on Chrome