Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

How set screen orientation to landscape with javascript?

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.

SNOOPP
Posts: 0
Joined: Tue Feb 25, 2014 2:57 pm

How set screen orientation to landscape with javascript?

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.

SNOOPP
Posts: 0
Joined: Tue Feb 25, 2014 2:57 pm

How set screen orientation to landscape with javascript?

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.

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

How set screen orientation to landscape with javascript?

You can search more information online, but looks like it's not possible to lock orientation for one screen only

Kal
Posts: 0
Joined: Thu May 22, 2014 11:03 pm

How set screen orientation to landscape with javascript?

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.

Kal
Posts: 0
Joined: Thu May 22, 2014 11:03 pm

How set screen orientation to landscape with javascript?

Found the answer, I need to look at window.orientation property, 90 and -90 mean landscape, otherwise portrait.

Thanks,
-Kal.

Alena Prykhodko
Posts: 0
Joined: Tue Apr 09, 2013 7:36 am

How set screen orientation to landscape with javascript?

Thumbs up! Thank you for update.

She
Posts: 0
Joined: Wed Oct 08, 2014 12:46 am

How set screen orientation to landscape with javascript?

where should i add this code? in pageshow event?

She
Posts: 0
Joined: Wed Oct 08, 2014 12:46 am

How set screen orientation to landscape with javascript?

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&#46;orientation < 0) &#47;&#47; Portrait
{
alert("portrait");
Apperyio("MainMenuPanel")&#46;attr("data-dismissible",true);
} else &#47;&#47; Landscape
{
alert("landscape");
Apperyio("MainMenuPanel")&#46;panel("open");
Apperyio("MainMenuPanel")&#46;attr("data-dismissible",'false');
}
});/code

Thank you,

She
Posts: 0
Joined: Wed Oct 08, 2014 12:46 am

How set screen orientation to landscape with javascript?

i alreay figured this problem by the ff code:

code

$( window )&#46;on( "orientationchange", function( event ) {
&#47;&#47;alert( "This device is in " + event&#46;orientation + " mode!" );
if(event&#46;orientation=="portrait"){
alert("portrait");
}else{
alert("landscape");
}
});
/code

Return to “Issues”