Catatan
Akses ke halaman ini memerlukan otorisasi. Anda dapat mencoba masuk atau mengubah direktori.
Akses ke halaman ini memerlukan otorisasi. Anda dapat mencoba mengubah direktori.
Peristiwa ini dipanggil oleh klien saat tab dialihkan ke tab lain. Peristiwa ini memungkinkan penangan sisi klien untuk bereaksi terhadap sakelar tab, memperbarui antarmuka pengguna atau status internal sesuai kebutuhan. ON_TAB_SWITCH peristiwa mengambil eventData berikut.
| Data peristiwa | Description |
|---|---|
| sebelumnyaSessionId | ID sesi tab sebelumnya. |
| sebelumnyaTabId | ID tab tab tab sebelumnya. |
| SessionId | ID sesi tab yang sekarang difokuskan. |
| tabId | ID tab yang sekarang difokuskan. |
Example
// 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
Contoh kode menggunakan Broadcast Channel API - Web API untuk berkomunikasi antara dokumen yang berbeda seperti halaman atau iframe yang berasal dari tujuan yang sama. Pastikan ini kompatibel dengan penyesuaian Anda karena dukungan untuk API ini dapat bervariasi.