找不到js对象怎么办?

starry11 2006-04-20 04:18:21
因为页面上某个操作耗时较久,所以在程序里用了下面的方法提示用户等待:
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 很不熟悉,希望各位高手不吝赐教,谢谢
...全文
328 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
starry11 2006-04-21
  • 打赏
  • 举报
回复
没有人会吗?着急啊~~
sunchaohuang 2006-04-20
  • 打赏
  • 举报
回复
帮你顶一下
starry11 2006-04-20
  • 打赏
  • 举报
回复
试了 menuvb(戏子……年少,轻狂,不张扬) 的方法,还是报告说mydiv没有定义 :(
menuvb 2006-04-20
  • 打赏
  • 举报
回复
抱歉。看错了。

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");
menuvb 2006-04-20
  • 打赏
  • 举报
回复
Response.Write("<script>mydiv.innerText = '';</script>");

你的页面上因为没有mydiv的标签。而且JS代码也写错的

62,046

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧