אירוע ON_TAB_SWITCH

אירוע זה מופעל על-ידי הלקוח כאשר כרטיסיה מועברת לכרטיסיה אחרת. אירוע זה מאפשר למטפלים בצד הלקוח להגיב לבוררי כרטיסיות, ולעדכן את ממשק המשתמש או המצב הפנימי לפי הצורך. אירוע ON_TAB_SWITCH מקבל את ה- eventData הבא.

eventData תיאור
קודםSessionId מזהה ההפעלה של הכרטיסיה הקודמת.
קודםTabId מזהה הכרטיסיה של הכרטיסיה הקודמת.
מזהה סשן מזהה ההפעלה של הכרטיסיה הממוקדת כעת.
מזהה tabId מזהה הכרטיסיה הממוקדת כעת.

דוגמה


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

הערה

דוגמת הקוד משתמשת בממשק ה-API של ערוץ השידור - ממשקי API של אינטרנט כדי לתקשר בין מסמכים שונים כגון דפים או iframes מאותו מקור. ודא שהוא תואם להתאמה האישית שלך מכיוון שהתמיכה ב-API זה עשויה להשתנות.