ON_TAB_SWITCH eveniment

Acest eveniment este invocat de client atunci când o filă este comutată la o altă filă. Acest eveniment permite handlerilor din partea clientului să reacționeze la comutatoarele de file, actualizând interfața cu utilizatorul sau starea internă după cum este necesar. ON_TAB_SWITCH eveniment ia următorul eventData.

date de eveniment Descriere
previousSessionId ID-ul sesiunii din fila anterioară.
anteriorTabId ID-ul filei din fila anterioară.
Idul de sesiune ID-ul de sesiune al filei care este acum focalizată.
tabId ID-ul filei care este acum focalizată.

Exemplu


// 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; 

Notă

Eșantionul de cod utilizează API-ul Canal de difuzare - API-uri web pentru a comunica între diferite documente, cum ar fi pagini sau iframe-uri care sunt de aceeași origine. Asigurați-vă că este compatibil cu personalizarea dvs., deoarece suportul pentru acest API poate varia.