This component provides a reusable browser visibility detection and notification framework for OutSystems Reactive Web applications.
The solution enables:
Browser tab switch detection
Active/inactive tab monitoring
Screen-level event handling
Browser/system notifications
Reusable event-driven architecture
The implementation uses:
JavaScript Browser Visibility API
JavaScript Notification API
OutSystems Reactive Web blocks and events
Detects:
User switching tabs
Browser minimize/restore
Returning to application tab
Reusable block events:
OnTabHidden
OnTabVisible
Displays browser/system notifications with:
Title
Message
Can be added to any screen or layout.
Reusable block responsible for:
Detecting browser visibility changes
Triggering OutSystems events
Reusable notification handler responsible for:
Requesting browser notification permission
Triggering browser notifications
Import or create:
TabVisibilityListener
BrowserNotification
inside your OutSystems module.
Drag the TabVisibilityListener block into:
Screenor
Common Layout
Recommended:Add to the application layout for global monitoring.
Inside the TabVisibilityListener block:
Open OnReady
OnReady
Add a RunJavaScript node
RunJavaScript
Add the following JavaScript:
if (!window.visibilityListenerAdded) { window.visibilityListenerAdded = true; document.addEventListener("visibilitychange", () => { if (document.hidden) { $actions.OnTabHidden(); } else { $actions.OnTabVisible(); } }); }
The screen can subscribe to:
Example use cases:
Update user status
Pause live refresh
Trigger notifications
Save activity logs
Auto-away handling
Inside the BrowserNotification action:
Example implementation:
Notification.requestPermission().then(permission => { if (permission === "granted") { new Notification($parameters.Title, { body: $parameters.Message }); } });
User switches browser tab ↓ visibilitychange event detected ↓ OnTabHidden event triggered ↓ Screen handles event ↓ BrowserNotification action called ↓ Notification displayed
Example:
Title: Approval Pending
Approval Pending
Message: A procurement request requires your approval.
A procurement request requires your approval.
Browser notifications require:
HTTPSor
localhost
Notifications may not work correctly on unsecured HTTP environments.
window.visibilityListenerAdded
to prevent multiple event registrations during screen rerenders.
Users must allow browser notifications before notifications can be displayed.
The framework can detect:
Current tab visibility state
The framework cannot detect:
Other website names
Browser history
Exact user activity outside the application
Recommended for:
Procurement applications
Chat systems
Approval workflows
Real-time dashboards
Presence tracking
Live support systems
Add listener block only once per screen/layout
Use centralized notification handling
Avoid excessive notification triggering
Use throttling for repeated events
Store user notification preferences if required
Possible enhancements:
Idle detection
Multi-tab synchronization
Online/away/offline presence
Push notifications
Firebase integration
Notification click handling
Background notifications
User activity analytics
TabVisibilityListener Block ↓ Detect Browser Visibility Changes ↓ Trigger OutSystems Events ↓ Screen Handles Events ↓ BrowserNotification Action Invoked ↓ Browser/System Notification Displayed
This implementation provides a scalable and reusable browser activity monitoring and notification framework for OutSystems Reactive Web applications.