I am trying to send some data for analytics on browser close and the visibilitychange event listener is not being triggered on browser close on firefox. This works as expected in chrome.
document.addEventListener('visibilitychange', () => {
if(document.visibilityState === 'hidden') {
navigator.sendBeacon('http://localhost:3001')
}
})
New contributor
prajot surey is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1