Alert On Prolonged Mouseover

[Total: 0    Average: 0/5]

Do you want a script that can detect a prolonged mouseover?

Head Code:

<script>
var WAIT_IN_MSECS=3000; /* 3 seconds */
var timer=null;
function doIt(_v)
{
  if(_v)
  {
    timer=setTimeout('doAction()',WAIT_IN_MSECS);
  }
  else
  {
    if(timer)
	{
	  clearTimeout(timer);
	  timer=null;
	}
  }
}
function doAction()
{
   alert("You waited 3 seconds");
}
</script>

Body Code:

<span onmouseover="doIt(true)" onmouseout="doIt(false)">
Go ahead and mouse over this text - and wait for 3 seconds
</span>

Times Viewed: 0

Leave a Reply

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