只要把这写在加载方法的前面就可以了:
运用的时候要把背景图片更换一下
public void Loading()
{
HttpContext hc = HttpContext.Current;
//创建一个页面居中的dibody >
// hc.Response.Write("<body style='-moz-opacity:0.25;filter:alpha(opacity=50);'> <form id='jiazai' runat='server'> ");
hc.Response.Write("<div id='loading'style='position:absolute; background-color:#118FE9; border:#8BD0F6 1px solid; height: 100px; text-align: center;z-index: 9999; left: 50%; top: 50%; margin-top: -50px; margin-left: -175px;'> ");
hc.Response.Write("<br />页面正在加载中,请稍候……<br /><br /> ");
hc.Response.Write("<table border='1' cellpadding='0' cellspacing='0' style='background-image: url(images/plan-bg.gif);text-align: center; width: 300px;'> ");
hc.Response.Write("<tr><td style='height: 20px; text-align: center'><marquee direction='right' scrollamount='30' width='290px'> <img height='10' src='images/plan-wait.gif' width='270' />");
hc.Response.Write("</marquee></td></tr></table></div>");
// hc.Response.Write("<script>mydiv.innerText = '';</script>");
hc.Response.Write("<script type=text/javascript>");
//最重要是这句了,重写文档的onreadystatechange事件,判断文档是否加载完毕
hc.Response.Write("function document.onreadystatechange()");
hc.Response.Write(@"{ try
{
if (document.readyState == 'complete')
{
delNode('loading');
}
}
catch(e)
{
alert('页面加载失败!');
}
}
function delNode(nodeId)
{
try
{
var div =document.getElementById(nodeId);
if(div !==null)
{
div.parentNode.removeChild(div);
div=null;
CollectGarbage();
}
}
catch(e)
{
alert('删除ID为'+nodeId+'的节点出现异常');
}
}
");
hc.Response.Write("</script>");
// hc.Response.Write(" </form> </body>");
hc.Response.Flush();
}