iFrame activity detection capability
š§ Activity Detection ā postMessage Integration
postMessage Integrationš Purpose
To help the host application detect user activity within an embedded Worklio iFrame and manage session timeouts accordingly.
š” Behavior
The embedded Worklio iFrame sends an activity signal to the parent window using:
window.parent.postMessage("activity", "*");- ā Triggered on: mouse movement or keyboard input inside the iFrame.
- ā±ļø Rate-limited: emitted no more than once per minute, even during continuous interaction.
š ļø Host App Integration
To capture and validate activity messages securely:
// Replace with the actual URL of the embedded iFrame
var url = "https://api.worklio.com/DispatcherICU?...";
var origin = new URL(url).origin;
window.addEventListener("message", function (e) {
if (e.origin !== origin) return;
if (e.data === "activity") {
// Reset host timeout or mark session as active
console.log("User is active in iFrame");
}
});ā
Why Origin Check Is Important
Using window.parent.postMessage("activity", "*") allows cross-origin messages.
To prevent spoofed messages from other sources, always validate theorigin before processing the message.
š Notes
- You can store the iFrame
urldynamically if the session link is generated at runtime. - Adjust session timeout or activity tracking logic based on your appās UX and security needs.
Updated 11 months ago
Did this page help you?
