【问题标题】:How to change a cursor to wait while table is loading如何在表加载时更改光标以等待
【发布时间】:2013-10-09 19:14:10
【问题描述】:

所以我创建了一个刷新按钮,它调用了一个名为 refreshTable() 的函数。它刷新的表包含大量数据,因此我希望游标更改为等待游标,直到表完成加载。

目前我有

<asp:Button ID="RefreshBtn" Text="Refresh" OnClick="refreshTable" style="cursor:wait" runat="server"/>

当我悬停在按钮上方而不是当我单击按钮时,光标会变为等待。知道我做错了什么吗?

谢谢!

【问题讨论】:

    标签: javascript asp.net javascript-events


    【解决方案1】:

    您可以使用 javascript 实现它(可能将其嵌入到您现有的 refreshTable() 函数中)。

    首先,通过添加this 将按钮对象传递给onclick 中的函数:

    <asp:Button ID="RefreshBtn" Text="Refresh" OnClick="refreshTable(this)" runat="server"/>
    

    然后仅在调用函数时将样式应用于它:

    //the var btn is the button that you clicked
    refreshTable(btn){
    //...
    
    btn.style.cursor = 'wait';
    

    【讨论】:

      【解决方案2】:

      不幸的是,以上答案都不适合我。然而,我确实在这里找到了答案: http://forums.asp.net/t/1324613.aspx

      所以在 Page_load 中,我添加了以下行:

      this.RefreshBtn.Attributes.Add("onClick", "refreshTable()");
      

      然后在我的 refreshTable() 中添加:

      document.getElementById("RefreshBtn").style.cursor = "wait";
      

      【讨论】:

        【解决方案3】:

        您必须在加载发生时在所有内容之上添加一个div 绝对定位和cursor: wait。 例如添加一个具有以下 css 的 div:

        .wait-layer {
            position: absolute;
            left: 0;
            top: 0;
            right: 0;
            bottom: 0;
            cursor: wait;
            z-index: 100
        }
        

        这样整个屏幕都会有等待光标

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2010-10-08
          • 2018-04-08
          • 1970-01-01
          • 2011-04-23
          • 2012-03-29
          • 1970-01-01
          • 2010-12-06
          相关资源
          最近更新 更多