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.

EventDescription
webOSLaunchThis event is fired when an app is launched.
webOSRelaunchThis event is fired before an app's status is switched from the background state to the foreground state.
webOSLocaleChangeThis event is fired when the language is changed in the Settings.
webOSMouseThis event is fired depending on whether LG Magic Remote's pointer cursor is focused on an app.
keyboardStateChangeThis event is fired when the visibility status of the virtual keyboard is changed.
cursorStateChangeThis 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

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
NameTypeDescription
detailObjectThe object that has event information
NameTypeDescription
typeString
  • 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
detailObjectThe object that has event information
NameTypeDescription
visibilityBoolean
  • 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
detailObjectThe object that has event information
NameTypeDescription
visibilityBoolean
  • true: The pointer cursor appeared.
  • false: The pointer cursor disappeared.
See also
System UI Visibility
No Headings