Working With Orientation Of The Ipad In Javascript
I am working with the orientation in iPad . I am using phone gap for building the application. I have done following code for orientation change : function updateOrientatio
Solution 1:
Both Safari and Android support a simple orientation change event listener.
<!DOCTYPE HTML><html><head><metaname="viewport"content="width=320; user-scalable=no" /><metahttp-equiv="Content-type"content="text/html; charset=utf-8"><title>PhoneGap</title><scripttype="text/javascript"charset="utf-8"src="phonegap-1.1.0.js"></script><scripttype="text/javascript"charset="utf-8"src="main.js"></script></head><bodyonload="init();" ><h2>Orientation Test</h2><divid="status"></div></body></html>
And js code :
functioninit() {
window.addEventListener("orientationchange", orientationChange, true);
}
functionorientationChange(e) {
var orientation="portrait";
if(window.orientation == -90 || window.orientation == 90) orientation = "landscape";
document.getElementById("status").innerHTML+=orientation+"<br>";
}
Post a Comment for "Working With Orientation Of The Ipad In Javascript"