admin管理员组

文章数量:1431704

I want to "lock" the orientation of the website to portrait mode in safari 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.

I want to "lock" the orientation of the website to portrait mode in safari 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.

Share Improve this question edited Sep 25, 2018 at 18:54 Samuel Hulla 7,1398 gold badges42 silver badges79 bronze badges asked Sep 25, 2018 at 18:43 codeWithMecodeWithMe 8922 gold badges12 silver badges17 bronze badges 5
  • Possible duplicate of Blocking device rotation on mobile web pages – Ruzihm Commented Sep 25, 2018 at 18:46
  • Yeah well that did not work, and I require JavaScript only – codeWithMe Commented Sep 25, 2018 at 18:47
  • Everything under Edit 2 is pure javascript. – Ruzihm Commented Sep 25, 2018 at 18:48
  • Also, please edit your question to explain what happened in language more descriptive than "did not work". – Ruzihm Commented Sep 25, 2018 at 18:50
  • It gave me 2-3 errors, I'm not with my puter at the moment but I will give them tomorow. – codeWithMe Commented Sep 25, 2018 at 19:50
Add a ment  | 

1 Answer 1

Reset to default 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./chmanie/o9n

本文标签: mobileHow do I lock the screen orientation to portrait in Safari using plain JavaScriptStack Overflow