ON_TAB_SWITCH esdeveniment

Aquest esdeveniment és invocat pel client quan una pestanya es canvia a una altra pestanya. Aquest esdeveniment permet als controladors del costat del client reaccionar als commutadors de pestanya, actualitzant la interfície d'usuari o l'estat intern segons sigui necessari. ON_TAB_SWITCH esdeveniment pren el següent eventData.

eventData Descripció
previousSessionId L'identificador de sessió de la pestanya anterior.
anteriorTabId L'identificador de la pestanya anterior.
Identificador de sessió L'identificador de sessió de la pestanya que ara està enfocada.
tabId L'identificador de la pestanya que ara està enfocada.

Exemple


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

L'exemple de codi utilitza l'API del canal de difusió - API web per comunicar-se entre diferents documents, com ara pàgines o iframes del mateix origen. Assegureu-vos que sigui compatible amb la vostra personalització, ja que la compatibilitat amb aquesta API pot variar.