Does not work on iOS Web apps (homescreen)
A simple and good idea is the script. Unfortunately, it only works for pages that are called directly in the browser (Safari). If you use the web app functions in iOS and place a link on the homescreen it doesn't work. Example: http://Piepmatz.einzelfabrik.de/index4.php In my case I only want to allow portrait mode - and forbid landscape.
What can I change?
@einzelfabrik are you found something else?
Had the same issue and solved the problem by modifying the isPortrait() function in pleaserotate.js (line 179) to use another viewport measure than window.innerWidth/innerHeight, which seems to be spotty on iOS:
iOS return bad value for window.innerHeight/Width
In my case I went for document.documentElement.clientWidth/clientHeight (mentioned in the link above) and it works perfectly in both webapp/browser modes now.
function isPortrait(){
return (document.documentElement.clientWidth < document.documentElement.clientHeight);
}
Hope it helps!
Thanks @equinoxe3d -- if this solution has better cross-browser / platform compatibility I'd be happy to merge in a PR with it.