Skyler Spaeth
Skyler Spaeth

Reputation: 193

Detect iOS orientation relative to the home button in JavaScript?

How can I detect an iOS devices orientation relative it's home button in JavaScript?

Upvotes: 0

Views: 66

Answers (1)

beyowulf
beyowulf

Reputation: 15321

As mentioned, you can use window.orientation. For example:

switch(window.orientation)
                {
                    case 0:
                        //"Portrait"
                    break;

                    case -90:
                        //"Landscape (right, screen turned clockwise)"
                    break;

                    case 90:
                        //"Landscape (left, screen turned counterclockwise)"
                    break;

                    case 180:
                        //"Portrait (upside-down portrait)"
                    break;

                }

For more information see here

Upvotes: 1

Related Questions