Sergio Sergio - 3 months ago 34
Javascript Question

Change orientation on Phonegap JQuery mobile

Hi i write simple app using jqm and phonegap, and i have some problem with change orientation. I need to change orientation on one page. I can change values "Supported interface orientations" but it work on all pages, may be exist way to change orientation on one page ?

Answer

You can use this plugin.

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

To lock the screen to Landscape:

navigator.screenOrientation.set('landscape');

To lock the screen to Portrait:

navigator.screenOrientation.set('portrait');

To unlock:

navigator.screenOrientation.set('fullSensor');