How to display mouse inactivity element?

Asked

Viewed 1,235 times

1

For example, the user enters the page and, while not moving the mouse after a certain time, an element appears.

  • i tried that $('.test'). Hide(). delay(1000). fadein 9000 in case it gets automatically presenting

  • I have the home screen ...if you do not move the mouse a div appears above the telainicial ...but this div can only appear if the person is a while without moving the mouse...

2 answers

1

Look at this example:

    $(function() {
    timeout = setTimeout(function() {
        window.location.href = "http://answall.com";
    }, 120000);
});

$(document).on('mousemove', function() {
    if (timeout !== null) { 
        clearTimeout(timeout);
    }
    timeout = setTimeout(function() {
        window.location.href = "http://answall.com";
    }, 120000);
    });

In this code, checks the movement of the mouse, if in two minutes the mouse is not moved it directs to another page using window.location.href.

So you just have to change the code by removing the window.location.href and acquiring the action that shows your DIV.

Source: Run action after 2 minutes without moving the mouse

0

About getting the mouse stopped I don’t know anything specific but you can do a javascript to display the div after some time... follow example:

<script type="text/javascript">

function carregar_tempo() {
document.getElementById('box').style.display='block';
}

</script>

<body onload="setTimeout('carregar_tempo()', 1000)">

<div id="box" style="display:none;">conteúdo</div>

1000 equals 1 second, only change.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.