Reputation: 563
i am using code to lock Orientation of one of page of my html app, but it seems not working , please guide what am i missing or way to fix it
document.addEventListener("intel.xdk.device.ready", onDeviceReady, false);
function onDeviceReady(){
intel.xdk.device.setRotateOrientation('landscape');
console.log('heyy');
intel.xdk.device.hideSplashScreen();
}
Upvotes: 0
Views: 313
Reputation: 637
It is a bit difficult to force a particular orientation on hybridsapps, because its different that you are using titanium or cordova, or if you are developping for Android, iOs or Windows.
I recommend using another perspective: attempts to detect the orientation of the device using JavaScript (for example, triggers an event when resizing the window, and compares the height to width), and display a warning so that only the web is read from the orientation that you want, or apply a transformation of 90 degrees to the body of the website for rotate it with the device.
Another option would be to apply a CSS style for each orientation.
function myFunction() {
var w = window.outerWidth;
var h = window.outerHeight;
var txt = "";
if (w < h) {
txt ="The windows is <b>PORTRAIT</b> mode";
} else if (h < w) {
txt ="The windows is <b>LANDSCAPE</b> mode";
} else {
txt ="The windows is <b>SQUARE</b> mode";
}
document.getElementById("demo").innerHTML = txt;
}
<body onresize="myFunction()" onload="myFunction()">
<p>Try to resize the browser window to emule the orientation change.</p>
<p id="demo"></p>
<p><strong>Note:</strong> this example will not work properly in IE8 and earlier. IE8 and earlier do not support the outerWidth/outerHeight propery of the window object.</p>
</body>
I'm sorry about my English.
Upvotes: 0