How can i change Screen Orientation using javascript or Jquery?

4,272 views
Skip to first unread message

Phone@gap

unread,
Jul 20, 2012, 12:29:23 AM7/20/12
to phon...@googlegroups.com
I am developing a application using Phonegap for Android and iphone. I need to change the screen orientation when i am navigating from one page to another. Can any one tell how it can be done through either java script or jquery ?

Thank you


naresh

unread,
Jul 20, 2012, 1:01:25 AM7/20/12
to phon...@googlegroups.com
i am facing same problem . including windows phone and Nokia also

Memo

unread,
Jul 20, 2012, 4:04:14 AM7/20/12
to phon...@googlegroups.com
Amen to that.  I found references on stack overflow and tried them to no avail.  Do we need to add in a custom hook or is there something available in the framework?  I  noted that it isn't documented, was it perhaps something pulled out of cordova?

--
-- You received this message because you are subscribed to the Google
Groups "phonegap" group.
To post to this group, send email to phon...@googlegroups.com
To unsubscribe from this group, send email to
phonegap+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/phonegap?hl=en?hl=en
 
For more info on PhoneGap or to download the code go to www.phonegap.com
 
To compile in the cloud, check out build.phonegap.com
 
 



--
~M

Giacomo Balli

unread,
Jul 20, 2012, 2:13:49 PM7/20/12
to phonegap
You can't "force" it an odds are you shouldn't (Design wise).
However, you can rotate the whole page using transformations all
though an extreme pain to layout (and make sure status bar is hidden).

Kerri Shotts

unread,
Jul 20, 2012, 3:30:30 PM7/20/12
to phon...@googlegroups.com
Pretty sure there is no JS-native method to force a particular orientation, but you could probably do it via a plugin of some sort. Not hard, I don't think, but not terribly easy to get right, either.

_________________________________________
~Kerri Shotts, photoKandy Studios LLC
   Wanna be our neighbor? Our Facebook page & Twitter feed.

Memo

unread,
Jul 21, 2012, 7:46:12 PM7/21/12
to phon...@googlegroups.com
Perhaps I misread this, but I meant detecting that the user has rotated the phone 90 degree or greater such that I can change the functionality of the software.

I was thinking this sort of thing:
http://stackoverflow.com/questions/5284878/how-do-i-correctly-detect-orientation-change-using-javascript-and-phonegap-in-io

Is it just me or does it not work?

Using iOS
--
~M

Memo

unread,
Jul 21, 2012, 7:53:50 PM7/21/12
to phon...@googlegroups.com
Nevermind, I caught my error (it works) and so to answer the original posters question:


"I am developing a application using Phonegap for Android and iphone. I need to change the screen orientation when i am navigating from one page to another. Can any one tell how it can be done through either java script or jquery ?"

Step one: intercept the page using pagebeforechange
step two: use a plugin like this

You can use this PhoneGap Plugin for Android:

https://github.com/champierre/pg-plugin-screen-orientation

And add to your index.html page onload:

navigator.screenOrientation.set('portrait');

Source: http://stackoverflow.com/questions/10348538/android-fix-screen-orientation-for-1-page-only-phonegap
--
~M

wernerz

unread,
Aug 12, 2012, 2:39:20 PM8/12/12
to phon...@googlegroups.com
Hi!

I do have the same orientation changing problem. The only answer I can find is a PlugIn for Android. Could you ever find a solution that works for iPhone?

Thank you,
Werner
Reply all
Reply to author
Forward
0 new messages