views:

18

answers:

1

I'd like to execute some JavaScript code when the mobile phone is rotated. 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?

+1  A: 

it should be "onorientationchange" event attached on <body> tag.

Looking at window.orientation property you should also get the angle in degrees.

Fabrizio Calderan