webOS Event

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. 

Open


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


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


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

Name

Type

Description

detail

Object

The object that has event information

Name

Type

Description

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('keyboradStateChange', function(event) {
    if (event.detail && event.detail.visibility) {
        // Do something
    } else {
        // Do something
    }
})

Properties

Name

Type

Description

detail

Object

The object that has event information

Name

Type

Description

visibility

Boolean

  • true: The virtual keyboard appeared.

  • false: The virtual keyboard disappeared.

See Also

Handling System UI Event


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

Name

Type

Description

detail

Object

The object that has event information

Name

Type

Description

visibility

Boolean

  • true: The pointer cursor appeared.

  • false: The pointer cursor disappeared.

See Also

Handling System UI Event


Navigation