I would like to display an image when the user clicks the back button of the browser. The code below worked fine in safari 15.5, but when I upgraded to safari 16.1, it did not work. Popstate not working in safari 16.1?
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<script>
history.replaceState(null, null, null)
history.pushState(null, null, null);
window.addEventListener('popstate', function () {
alert('fired');
});
</script>
</head>
<body>test</body>
</html>
I confirmed that when I clicked the browser back button in safari 15, the alert message was displayed. When I ran it in safari 16, nothing was executed and the previous page was displayed as is.