页面加载Loading(.net)

C#:

复制代码
protected override void OnInit(EventArgs e)
{
    Response.Write("<div id='mydiv'>_</div>");
    Response.Write("<script type='text/javascript'>document.getElementById('mydiv').innerHTML = '<img src=\"images/ajax-loader.gif\" />';</script>");
    Response.Write("<script type='text/javascript'>");
    Response.Write("function ShowWait(){}");
    Response.Write("function StartShowWait(){document.getElementById('mydiv').style.display = '';}");
    Response.Write("StartShowWait();");
    Response.Write("</script>");
    Response.Flush();
}
复制代码

HTML:

document.getElementById('mydiv').style.display = "none";
==================================================
孟子的进度效果:
复制代码
Response.Write("<div id='mydiv' >");
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.visibility = 'hidden';");
Response.Write("window.clearInterval();}");
Response.Write("StartShowWait();</script>");
Response.Flush();
Thread.Sleep(10000);
复制代码

 

posted @   CoderWayne  阅读(405)  评论(0编辑  收藏  举报
编辑推荐:
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
阅读排行:
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 单元测试从入门到精通
· 上周热点回顾(3.3-3.9)
· Vue3状态管理终极指南:Pinia保姆级教程
点击右上角即可分享
微信分享提示