Load a modal after 5 mins inactive in the browser

Load a modal after 5 mins inactive in the browser
<script type="text/javascript">

function idleTimer() {
    var t;

    window.onload  = resetTimer; # catches windows reload

    window.onmousemove  = resetTimer; # catches mouse movements

    window.onmousedown  = resetTimer; # catches mouse movements

    window.onclick  = resetTimer; # catches mouse clicks

    window.onscroll  = resetTimer; # catches scrolling

    window.onkeypress  = resetTimer; #catches keyboard actions


    function showModal() {

        #"Your idle time is 20 minutes over")

        #show modal now

    }


   function resetTimer() {

        clearTimeout(t);

        t = setTimeout(showModal, 1200000);  # [time is in milliseconds (1000 is 1 second)]

    }

}


# Execute the IdelTimer()
# idleTimer();

</script>
Please follow and like us:
0

Leave a Reply

Your email address will not be published. Required fields are marked *