Why doesn't ScreenOrientation: change event work on the mobile web (iOS Safari)?
I've made a web page and I want to reload the page whenever the orientation has been changed on a mobile. but location.reload(); is not working. I have tried alert("?"); but it's also not working.
The code that I used is below.
window.addEventListener("load", function() {
screen.orientation.addEventListener("change", (event) => {
location.reload();
});
});
At first, I used orientationchange. but I found it's deprecated and has one error which is showing the pop-up that asks "if you want to download the page" when orientation has been changed on iOS mobile phone (PC doesn't have that error). Now I'm using ScreenOrientation: change event instead.
I found that it only works on PC, and doesn't work on my mobile phone (iOS 16.6 Safari).
As I searched ScreenOrientation: change event, it should work on both mobile and PC.
Does anyone know why screen.orientation.addEventListener("change", (event) is not working on the mobile and what can I do?