pleaserotate.js icon indicating copy to clipboard operation
pleaserotate.js copied to clipboard

Does not work on iOS Web apps (homescreen)

Open einzelfabrik opened this issue 7 years ago • 3 comments

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 avatar Jul 04 '18 21:07 einzelfabrik

@einzelfabrik are you found something else?

WuglyakBolgoink avatar Dec 02 '19 16:12 WuglyakBolgoink

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!

equinoxe3d avatar Jan 06 '21 14:01 equinoxe3d

Thanks @equinoxe3d -- if this solution has better cross-browser / platform compatibility I'd be happy to merge in a PR with it.

arscan avatar Jan 06 '21 15:01 arscan