I encountered an issue with a code snippet I am using:
window.addEventListener("orientationchange", orientation);
Interestingly, the function orientation()
is not being triggered on an iPhone SE running iOS 10.3, but it does work on a Moto G running Android 5.1.
The purpose of this code is to update something based on the screen width. To handle browser differences, I utilize window.innerWidth
and screen.width
if they are undefined.
A glimpse at my orientation()
function reveals:
cpr = Math.floor(window.innerWidth/100) - 3;
if (navigator.userAgent.match(/iPhone|iPad|iPod/i) || navigator.userAgent.match(/Android/i)) cpr = Math.min(Math.floor(screen.width/100) - 1, 8);
if (!cpr || cpr <= 0) cpr = 1;
id('times').innerHTML = "";
updateTimes();
The code functions as expected, except for the iOS platform. Some troubleshooting led me to test it in Chrome developer tools' device viewer, where it worked flawlessly.
I sought assistance from various Stack Overflow threads but unfortunately, none provided a solution to my predicament.
To see the code in action, feel free to visit the website link: .
Your insights are greatly appreciated!