Can js/jQuery determine the orientation of the iPhone?

后端 未结 5 463
挽巷
挽巷 2020-12-04 16:31

Out of curiosity I\'ve been playing with jQuery to determine the browser\'s screen size, and it occurred to me that screen size could be used to determine whether or not a v

5条回答
  •  一个人的身影
    2020-12-04 16:36

    window.orientation will give you an integer that denotes the rotation. You can listen for orientation changes by adding an event to the body:

    
    

    Just on the off-chance that the link dies or gets moved at some point:

    Value  |  Description
    -------+-------------------------------------------------------------------------------
     0     |  Portrait orientation. This is the default value.
    -90    |  Landscape orientation with the screen turned clockwise.
     90    |  Landscape orientation with the screen turned counterclockwise.
     180   |  Portrait orientation with the screen turned upside down. This value is currently not supported on iPhone.
    

提交回复
热议问题