onOrientationChange - Orientation Change Script

Activates JavaScript code after the device where this browser is running has been rotated from portrait (vertical) to landscape (horizontal) or from landscape to portrait.

Category

events

Syntax

<xp:eventHandler event="onOrientationChange" attributes>content</xp:eventHandler>

Usage

In Design mode, click All Properties and look for onOrientationChange in the events category.

Available on the Single Page Application control.

Note: This event is new for Release 9.0.1

This event may be used to dynamically change the appearance of the content of a web application when a mobile device is rotated. Not all mobile devices support this event.

To fully support all mobile browsers, it may be necessary to also respond to the onResize event and to do a calculation to compute the orientation based on the window width and height ratio.

Examples

<xe:singlePageApp>
		<xp:eventHandler event="onOrientationChange" submit="false">
			<xe:this.script><![CDATA[
console.log("onOrientationChange "
    +"innerWidth:"+window.innerWidth+" innerHeight:"+window.innerHeight);
]]&gt;</xe:this.script>
		</xp:eventHandler>
</xe:singlePageApp>