webOS Events

webOS events allow web apps to register different event handlers on specific cases. Events are normally used in combination with functions, and the function will not be executed before the event occurs.

Event

Description

webOSLaunch

This event is fired when an app is launched.

webOSRelaunch

This event is fired before an app's status is switched from the background state to the foreground state.

webOSLocaleChange

This event is fired when the language is changed in the Settings.

webOSMouse

This event is fired depending on whether LG Magic Remote's pointer cursor is focused on an app.

keyboardStateChange

This event is fired when the visibility status of the virtual keyboard is changed.

cursorStateChange

This event is fired when the visibility status of LG Magic Remote's pointer cursor is changed.

webOSLaunch

Description

This event is fired when an app is launched. When the `DOMContentLoaded` event, which is triggered right after the HTML document loading of a running app, is completed, this event is delivered to the app.

Example

document.addEventListener('webOSLaunch', function()
{
  // Do something
}
)

See also

App Lifecycle Management

webOSRelaunch

Description

This event is fired before an app's status is switched from the background state to the foreground state.

Example

document.addEventListener('webOSRelaunch', function()
{
  // Do something
}
)

See also

App Lifecycle Management

webOSLocaleChange

Description

This event is fired when the language is changed in the Settings.

Example

document.addEventListener('webOSLocaleChange', function(){' '}
{
  // Do something like reloading redirection url
}
)

webOSMouse

Description

This event is fired depending on whether LG Magic Remote's pointer cursor is focused on an app. This event is similar to the `mouseenter` event and the `mouseleave` event of HTML5.

Example

document.addEventListener('webOSMouse', function(event) {
    var mouse = event.detail.type;
    if (mouse === 'Enter') {
        // Do something
    } else if ( mouse === 'Leave') {
        // Do something
    }
})

Properties

NameTypeDescription
detail
Object
The object that has event information.
NameTypeDescription
type
String
  • Enter: The pointer cursor enters the app area.
  • Leave: The pointer cursor goes out of the app area because the app might have switched to the background state, or the cursor might have focused on an overlay app or the popup toast.

keyboardStateChange

Description

This event is fired when the visibility status of the virtual keyboard is changed. The visibility status is changed depending on whether the virtual keyboard is activated or deactivated. The virtual keyboard is usually activated when input elements are focused.

Example

document.addEventListener('keyboardStateChange', function(event) {
    if (event.detail && event.detail.visibility) {
         // Do something
     } else {
         // Do something
     }
})

Properties

NameTypeDescription
detail
Object
The object that has event information.
NameTypeDescription
visibility
Boolean
  • true: The virtual keyboard appeared.
  • false: The virtual keyboard disappeared.

See also

System UI Visibility

cursorStateChange

Description

This event is fired when the visibility status of LG Magic Remote's pointer cursor is changed.

Example

document.addEventListener('cursorStateChange', function(event) {
    if (event.detail && event.detail.visibility) {
        // Do something
    } else {
        // Do something
    }
})

Properties

NameTypeDescription
detail
Object
The object that has event information.
NameTypeDescription
visibility
Boolean
  • true: The pointer cursor appeared.
  • false: The pointer cursor disappeared.

See also

System UI Visibility

No Headings