Changing display orientation in Symbian Web Runtime
This code snippet shows how to change the orientation of the display to "Portrait" or "Landscape".
Article Metadata
Code Example
Tested with
Devices(s): Nokia 5800 XpressMusic, Nokia 6220 Classic
Compatibility
Platform(s): S60 5th Edition, S60 3rd Edition FP2
Article
Keywords: widget.setDisplayPortrait(), widget.setDisplayLandscape()
Created: ivruban
(26 Feb 2009)
Last edited: hamishwillee
(04 Oct 2012)
Contents |
Source file: Relevant HTML components
<input type="button" value="Landscape" onclick="changeToLandscape();" />
<input type="button" value="Portrait" onclick="changeToPortrait();" />
Source file: JavaScript file
// Changes the orientation to landscape
function changeToLandscape() {
if (window.widget.isrotationsupported) {
window.widget.setDisplayLandscape();
} else {
alert("Display rotating is not supported.");
}
}
// Changes the orientation to portrait
function changeToPortrait(){
if (window.widget.isrotationsupported) {
window.widget.setDisplayPortrait();
} else {
alert("Display rotating is not supported.");
}
}
Postconditions
After starting the widget, the buttons "Landscape" and "Portrait" are shown.
- To change the display orientation to landscape, click the "Landscape" button.
- To change the display orientation to portrait, click the "Portrait" button.
Supplementary material
This code snippet is part of the stub concept, which means that it has been patched on top of a template application in order to be more useful to developers. The version of the WRT stub application used as a template in this snippet is v1.1.
- The patched, executable application that can be used to test the features described in this snippet is available for download at Media:ChangingLayout.zip.
- You can view all the changes that are required to implement the above-mentioned features. The changes are provided in unified diff and colour-coded diff (HTML) formats in Media:ChangingDisplayOrientation.diff.zip.
- For general information on applying the patch, see Using Diffs.
- For unpatched stub applications, see Example app stubs with logging framework.

