Can I specify a delay before the browser fires the rollover event?

I am working on an ASP.NET web application that requires a popup to pop up. I am using the OnMouseOver event and it works as expected. The problem is that the event is on the trigger; even accidentally hooking the mouse over the control causes a popup (which must then be manually dismissed). I want to add a delay so that fast navigation on the element in question does not trigger events. Is there a way to set such a delay, or is there another event I could use to get the same "slow rollover trigger event"?

0


source to share


2 answers


One solution that comes to mind might be better:

  • Call a onmouseover

    function after a delaysetTimeout

  • Inside the function, check if the mouse is actually over this element.


You can also use onmouseout

to clear setTimeout

, but then you will need to store the timer reference in a global variable to get it again.

+3


source


What I ended up with looks like this (oRow is a table row, but it could be any control):

function ItemMouseOver(oRow, "parameters for the popup") 
{
    oRow.showTimer = window.setTimeout(function() 
        { 
            alert('popup');
        }, 1000);
}
function ItemMouseOut(oRow)
{
    if (oRow.showTimer)
        window.clearTimeout(oRow.showTimer);

      

In the ASP.NET Grid View, the RowDataBound: event I added the following code:



protected void ReportGridView_RowDataBound(object sender, GridViewRowEventArgs e)
{
    if (e.Row.RowType == DataControlRowType.DataRow && (
        e.Row.RowState == DataControlRowState.Normal 
        || e.Row.RowState == DataControlRowState.Alternate))
    {
        // get the input values for the popup for the row (stuff deleted)
        e.Row.Attributes["onmouseover"] = "javascript:ItemMouseOver(this,
            "parameters for the popup");";
        e.Row.Attributes["onmouseout"] = "javascript:ItemMouseOut(this);";
    } 
}

      

This works great. Thank.

0


source







All Articles