ON_TAB_SWITCH evento

Este evento é invocado polo cliente cando se cambia unha pestana a outra pestana. Este evento permite aos xestores do lado do cliente reaccionar aos interruptores de pestanas, actualizando a interface de usuario ou o estado interno segundo sexa necesario. ON_TAB_SWITCH evento leva o seguinte eventData.

Datos de eventos Descripción
Identificador de sesión anterior O ID da sesión da pestana anterior.
TabId anterior O ID do separador da pestana anterior.
Identificador de sesión O ID de sesión da pestana que agora está enfocada.
tabId O ID da pestana que agora está enfocada.

Exemplo


// Define a handler function that's triggered when the tab is switched
let tabSwitchedHandlerFunction = function(eventInput) {
    // Log the previous and new session IDs and tabs IDs to the console
    console.log("Previous session:  " + eventInput.data.previousSessionId + 
                " Previous tab: " + eventInput.data.previousTabId +
                " Current session: " + eventInput.data.sessionId + 
                " Previous tab: " + eventInput.data.tabId );

}; 

// Retrieve the event topic specific to tab switching from the API
let tabSwitchTopic = Microsoft.Apm.getEventPublisherTopic("ON_TAB_SWITCH");
// Create a new broadcast channel to subscribe to tab switch events
let tabSwitchSubscriber = new BroadcastChannel(tabSwitchTopic);
// Attach the tab switched handler function to the message event of the subscriber
tabSwitchSubscriber.onmessage = tabSwitchedHandlerFunction; 

Nota

A mostra de código usa a API de canle de transmisión - API web para comunicarse entre diferentes documentos, como páxinas ou iframes que son da mesma orixe. Asegúrese de que sexa compatible coa súa personalización, xa que o soporte para esta API pode variar.