WebAPI/ScreenOrientation
< WebAPI
Jump to navigation
Jump to search
Proposed API
partial interface Screen {
readonly attribute DOMString orientation;
attribute Function onorientationchange;
boolean lockOrientation(DOMString orientation);
}
The Screen object is a property of the Window object and has existed since DOM Level 0 (i.e. for a really long time). This API adds three new properties to the object.
The orientation attribute is either "landscape-primary", "landscape-secondary", "portrait-primary" or "portrait-secondary". The reason for these values rather than "upsidedown" or something similar is that some devices are by default in landscape mode (desktop/tablets) and some devices (most mobile) are by default in portrait mode.
Whenever the device orientation changes, an "orientationchange" event is fired on the Screen object *before* the rotation happens.