79143635

Date: 2024-10-31 06:07:03
Score: 0.5
Natty:
Report link

you need to Address this by binding a Document Visibility Tracker. Here's a sample function and you can add more actions like popup, warning or ending something as per your requirement.

enter image description here

To Bind it, add the JS to your form and bind it to OnLoad and OnSave Events like this

enter image description here

Function:

var ActivityTracking = {
init: function() {
    console.log("Initializing Activity Tracking with visibilitychange");

    document.addEventListener("visibilitychange", function() {
        if (document.hidden) {
            ActivityTracking.userLeftTab();
        } else {
            ActivityTracking.userReturnedToTab();
        }
    });
},

userLeftTab: function() {
    console.log("User has navigated away from the tab.");
    // Add any additional behavior you want here, like tracking or alerts
},

userReturnedToTab: function() {
    console.log("User has returned to the tab.");
    // Add any additional behavior you want here, like tracking or alerts
    }
};
ActivityTracking.init();
Reasons:
  • Probably link only (1):
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: Laviza Falak Naz