1

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
  • 5,914
  • 6
  • 30
  • 57
codeWithMe
  • 814
  • 9
  • 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
  • 4,693
  • 4
  • 21
  • 46
0

maybe using "windows.screen" work for you;

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