Newer Version Available

This content describes an older version of this product. View Latest

showWhenOnline

Use the showWhenOnline method to specify what customers see when particular button is online.

Usage

Displays a particular element when the specified button is online. Available in API versions 28.0 and later.

Syntax

void showWhenOnline(String buttonId, Object element, (optional) String userId)

Parameters

Name Type Description Available Versions
buttonId String The ID of the chat button for which to display the specified element object when agents associated with the button are available to chat. Available in API versions 28.0 and later.
element Object The element to display when the specified button is online. Available in API versions 28.0 and later.
(Optional) userId String The ID of the agent to associate with the button. The element object displays when that agent is available. Available in API versions 29.0 and later.

If you specify a button ID but not an agent ID in your parameters, the element will only display if the button is online.

If you specify an agent ID but not a button ID, the element will only display if the agent is online. For example, the syntax below tracks an agent’s online status and sets the button to online when that agent is available; however, the button is set to offline if that agent isn’t available.
1liveagent.showWhenOnline('005xx000001Sv1m', document.getElementById('liveagent_button_toAgent_online')
If you specify both a button ID and an agent ID, the element will display if either the button or the agent is online. For example, the syntax below tracks the status of both an agent and a button and displays the element if at least one is available.
1liveagent.showWhenOnline('573xx0000000006', document.getElementById('liveagent_button_online_573xx0000000006_USER1'), '005xx000001Sv1m');