lundi 24 octobre 2016

how to capture idle time in iframe jquery

I have a jquery or javascript that checks if u active on a webpage and it works great.It is currently in my idex.php (page that loads after login) my problem is that this script does not or is not able to capture activity in an iframe.

var IDLE_TIMEOUT = 10; //seconds
        var _idleSecondsCounter = 0;

        console.log(IDLE_TIMEOUT);

        document.onclick = function () {
            _idleSecondsCounter = 0;
            console.log("onclick");
        };

        document.onmousemove = function () {
            _idleSecondsCounter = 0;
            console.log("onmousemove");
        };

        document.onkeypress = function () {
            _idleSecondsCounter = 0;
            console.log("onkeypress");
        };

        window.setInterval(CheckIdleTime, 1000);

        function CheckIdleTime() {
            _idleSecondsCounter++;
            var oPanel = document.getElementById("SecondsUntilExpire");
            if (oPanel)
                oPanel.innerHTML = (IDLE_TIMEOUT - _idleSecondsCounter) + "";
            if (_idleSecondsCounter >= IDLE_TIMEOUT) {
                alert("Time expired!");

            }
        }




Aucun commentaire:

Enregistrer un commentaire