$(window).bind("orientationchange", function(){
var orientation = window.orientation;
var new_orientation = (orientation) ? 0 : 180 + orientation;
$('body').css({
"-webkit-transform": "rotate(" + new_orientation + "deg)"
});
});
This is risky, but thinks this is the only way.
An alternative that you can bind to a window resize event.
$(window).bind("resize", function(){
var orientation = window.orientation;
var new_orientation = (orientation) ? 0 : 180 + orientation;
$('body').css({
"-webkit-transform": "rotate(" + new_orientation + "deg)"
});
});
I recently wrote this little script: I fixed a multiply error with resizing on iOS safari and a change / one-trigger (1) changeroid error in android.
(1) Sometimes it does not start sometimes before and several times after the browser changes the width + height? Wired!
if (!(/iphone|ipad/gi).test(navigator.appVersion)) {
$(window).unbind("resize").bind("resize", function() {
$(window).trigger("orientationchange");
});
}
If you are not an iphone or ipad, you raise the changechange event in the window.
Therefore, when you bind any function, change its size, change the orientation.
: http://jsfiddle.net/aalouv/sABRQ/1/