开发者

Hooking into browser rotation

开发者 https://www.devze.com 2023-01-19 09:10 出处:网络
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?

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消