页面加载进度条(通过HTTP响应输出)

 只要把这写在加载方法的前面就可以了:

运用的时候要把背景图片更换一下

    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();

    } 


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值