因为页面上某个操作耗时较久,所以在程序里用了下面的方法提示用户等待:
Response.Write("<div id='mydiv'style='Z-INDEX: 101; LEFT: 80px; POSITION: absolute; TOP: 122px'>");
Response.Write("_");
Response.Write("</div>");
Response.Write("<script>mydiv.innerText = '';</script>");
Response.Write("<script language=javascript>;");
Response.Write("var dots = 0;var dotmax = 10;function ShowWait()");
Response.Write("{var output; output = '请等待';dots++;if(dots>=dotmax)dots=1;");
Response.Write("for(var x = 0;x < dots;x++){output += '·';}mydiv.innerText =  output;}");
Response.Write("function StartShowWait(){mydiv.style.visibility = 'visible'; ");
Response.Write("window.setInterval('ShowWait()',1000);}");
Response.Write("function HideWait(){mydiv.style.display='none';"); //.visibility = 'hidden'
//Response.Write("function HideWait(){location.href='" + strUrl + "';");
Response.Write("window.clearInterval();}");
Response.Write("StartShowWait();</script>");
Response.Flush();
Thread.Sleep(10000);并 在aspx页面上添加了
<script>
HideWait();
</script>提示功能虽然实现了,可是这个页面上还有个列表,列表翻页的时候总会提示说"找不到对象".
我想是因为缺少HideWait函数,于是就定义了一个内容为空的HideWait函数.但新的问题又出现了,这次是提示"mydiv未定义",我在页面上声明了一个mydiv,但是没有用.我对java script 很不熟悉,希望各位高手不吝赐教,谢谢

解决方案 »

  1.   

    Response.Write("<script>mydiv.innerText = '';</script>");你的页面上因为没有mydiv的标签。而且JS代码也写错的
      

  2.   

    抱歉。看错了。Response.Write("<div id='mydiv'style='Z-INDEX: 101; LEFT: 80px; POSITION: absolute; TOP: 122px'>");
    Response.Write("_");
    Response.Write("</div>");
    Response.Write("<script language=javascript>;");
    Response.Write("var mydiv=document.getElementById("mydiv");");
    Response.Write("var dots = 0;var dotmax = 10;function ShowWait()");
    Response.Write("{var output; output = '请等待';dots++;if(dots>=dotmax)dots=1;");
    Response.Write("for(var x = 0;x < dots;x++){output += '·';}mydiv.innerText = output;}");
    Response.Write("function StartShowWait(){mydiv.style.visibility = 'visible'; ");
    Response.Write("window.setInterval('ShowWait()',1000);}");
    Response.Write("function HideWait(){mydiv.style.display='none';"); //.visibility = 'hidden'
    //Response.Write("function HideWait(){location.href='" + strUrl + "';");
    Response.Write("window.clearInterval();}");
    Response.Write("StartShowWait();</script>");这样试试var mydiv=document.getElementById("mydiv");
      

  3.   

    试了 menuvb(戏子……年少,轻狂,不张扬) 的方法,还是报告说mydiv没有定义 :(