Page 2 of 2
How set screen orientation to landscape with javascript?
Posted: Thu Feb 27, 2014 11:30 am
by Maryna Brodina
Code pre$(window).bind('orientationchange', function(e) {
/* do something */
});/pre works for us. Could you clarify where did you add this code? What did you add on this event? Please try to add alert instead of this event and check if it works for you.
How set screen orientation to landscape with javascript?
Posted: Thu Feb 27, 2014 1:04 pm
by SNOOPP
jep, orientation change detection works fine, buut i dont need to do something when its changed, all i need is just set one screen orientation to landscape when screen loads, nothing more.
How set screen orientation to landscape with javascript?
Posted: Thu Feb 27, 2014 1:04 pm
by SNOOPP
jep, orientation change detection works fine, buut i dont need to do something when its changed, all i need is just set one screen orientation to landscape when screen loads, nothing more.
How set screen orientation to landscape with javascript?
Posted: Thu Feb 27, 2014 2:36 pm
by Maryna Brodina
You can search more information online, but looks like it's not possible to lock orientation for one screen only
How set screen orientation to landscape with javascript?
Posted: Fri Aug 08, 2014 12:29 am
by Kal
Maryna, I was searching for a solution to the same problem and found this post. I did a quick test, and the cod above works. However, I am not sure what the structure of the "e" object is, and how I can determine "portrait" or "landscape" from this object.
Do you know?
Thanks,
-Kal.
How set screen orientation to landscape with javascript?
Posted: Fri Aug 08, 2014 4:44 am
by Kal
Found the answer, I need to look at window.orientation property, 90 and -90 mean landscape, otherwise portrait.
Thanks,
-Kal.
How set screen orientation to landscape with javascript?
Posted: Fri Aug 08, 2014 5:01 am
by Alena Prykhodko
Thumbs up! Thank you for update.
How set screen orientation to landscape with javascript?
Posted: Tue Aug 04, 2015 6:03 am
by She
where should i add this code? in pageshow event?
How set screen orientation to landscape with javascript?
Posted: Tue Aug 04, 2015 7:54 am
by She
Hi Team,
I need your help, please i need it fast.
i want to create an app that the apps detect landscape it will opens the panel and lock the panel, i tried to do this code:
code
$(window).bind('orientationchange', function(e) {
if (window.orientation < 0) // Portrait
{
alert("portrait");
Apperyio("MainMenuPanel").attr("data-dismissible",true);
} else // Landscape
{
alert("landscape");
Apperyio("MainMenuPanel").panel("open");
Apperyio("MainMenuPanel").attr("data-dismissible",'false');
}
});/code
Thank you,
How set screen orientation to landscape with javascript?
Posted: Tue Aug 04, 2015 8:19 am
by She
i alreay figured this problem by the ff code:
code
$( window ).on( "orientationchange", function( event ) {
//alert( "This device is in " + event.orientation + " mode!" );
if(event.orientation=="portrait"){
alert("portrait");
}else{
alert("landscape");
}
});
/code