Hooking into browser rotation
I'd like to execute some JavaScript
code when the mobile phone is rotated.开发者_JAVA百科 I'm using jQuery
. Is there a custom hook I can use with mobile browsers?
One way I can think of is hooking into the change of the viewport size, and checking if the height/width ratio has changed. Is there an API method that I could use instead?
it should be "onorientationchange" event attached on <body> tag.
Looking at window.orientation property you should also get the angle in degrees.
精彩评论