【问题标题】:Onmouseover Hand icon not displaying鼠标悬停手形图标不显示
【发布时间】:2012-07-27 17:30:57
【问题描述】:

我有一个网格视图:

    <asp:GridView ID="gvwProd" runat="server" CssClass="gridview" ShowHeaderWhenEmpty="true"
                                        AllowPaging="true" BackColor="ButtonFace" OnRowDataBound="gvwProd_OnRowDataBound"
                                        OnRowCreated="gvwProd_RowCreated" OnSorting="gvw_OnSorting" AllowSorting="true"
                                        AutoGenerateColumns="false" ShowFooter="false">

我正在尝试为每一行的特定单元格设置手悬停图标:

protected void gvwProd_OnRowDataBound(object sender, GridViewRowEventArgs e)
{
    if (e.Row.RowType == DataControlRowType.DataRow)
    {
        e.Row.Cells[2].Attributes.Add("onmouseover", "document.body.style.cursor='hand'");
        e.Row.Cells[2].Attributes.Add("onmouseout", "document.body.style.cursor='auto'");
    }
}

onmousover 和 onmouseout 事件出现在标记中:

    <td onmouseover="document.body.style.cursor=&#39;hand&#39;" onmouseout="document.body.style.cursor=&#39;auto&#39;" style="white-space:nowrap;">05-07-2012</td>

但是,没有可见的手迹,也似乎没有发生任何事情。我究竟做错了什么?使用 IE 8

【问题讨论】:

    标签: asp.net onmouseover onmouseout


    【解决方案1】:

    首先:使用cursor: pointer 而不是cursor: hand(如果您希望它在多个浏览器中工作)

    第二:而不是使用document.body 我会使用this:

    e.Row.Cells[2].Attributes.Add("onmouseover", "this.style.cursor='pointer'");
    

    因为您希望光标悬停在单元格上。

    【讨论】:

      猜你喜欢
      • 2019-12-27
      • 2017-03-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多