I\'m developing one of those warning windows that tells the user that they may have unsaved data, but I only need it to warn them if they\'re leaving the page. Currently it
I think that the active element is not a valid solution.
I can't comment the "open and free" solution, I dont have reputation.
document.getActiveElement gets the currently focused element in the document. If a link have the focus and I press F5 or I close the tab the active element is the link.