2

I want to "lock" the orientation of the website to portrait mode in using pure javascript.

Let's say that I am building an application, I don't want users to be able to visit my app in landscape-mode. How do I do that?


Edit: I make the app in web-languages, I will assign it as a profile so anyone can download it on iPhone, so nothing with xCode or something.

Samuel Hulla
  • 6,617
  • 7
  • 36
  • 70
codeWithMe
  • 852
  • 12
  • 17

2 Answers2

1

the screen.lockOrientation method is not supported by Safari, so you'll have to do feature detection.

For Safari, you might try the ponyfill: https://github.com/chmanie/o9n

Benny Powers
  • 5,398
  • 4
  • 32
  • 55
0

maybe using "windows.screen" work for you;

var alowed = window.screen.orientation.lock("portrait");