Allow only one open browser window/tab per user/application

<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="">
            var secondsIamAliveInterval = 5;
            var tabId = sessionStorage.getItem("tabId");
            if (!tabId) {
                tabId = Math.random();
                sessionStorage.setItem("tabId", tabId);
            function sendTabIdToServer() {
                XSP.partialRefreshGet("#{id:browserTabControl}", {
                    params: {'tabId': tabId}
            setInterval(function() {
            }, secondsIamAliveInterval * 1000);
    <xp:panel id="browserTabControl">
            var secondsIgnoreOtherSession = 7;
            if (param.tabId) {
                var userName = session.getEffectiveUserName();
                var userData = applicationScope.get(userName);
                var now = new Date().getTime();
                if (userData) {
                    if (userData.tabId !== param.tabId) {
                        if (userData.time + secondsIgnoreOtherSession*1000 > now) {
                applicationScope.put(userName, {tabId : param.tabId, time: now});
            return true
All code submitted to OpenNTF XSnippets, whether submitted as a "Snippet" or in the body of a Comment, is provided under the Apache License Version 2.0. See Terms of Use for full details.
1 comment(s)Login first to comment...
Bill Fox
(at 13:24 on 04.03.2015)
This works really well with a browser, but causes the screen to flicker every time it does an "I am Alive" in the Notes client. I have set the run on server in the Notes Client but that does not appear to help. The screen flicker makes it almost unusable in the Notes Client.