码迷,mamicode.com
首页 > 其他好文 > 详细

页面缓冲显示正在加载图片

时间:2014-07-22 22:37:14      阅读:159      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   java   color   os   

一.代码部分

        public static void initJavascript()
        {
        HttpContext.Current.Response.Write(" <script language=JavaScript type=text/javascript>");
        HttpContext.Current.Response.Write("var t_id = setInterval(animate,20);");
        HttpContext.Current.Response.Write("var pos=0;var dir=2;var len=0;");
        HttpContext.Current.Response.Write("function animate(){");
        HttpContext.Current.Response.Write("var elem = document.getElementById(‘progress‘);");
        HttpContext.Current.Response.Write("if(elem != null) {");
        HttpContext.Current.Response.Write("if (pos==0) len += dir;");
        HttpContext.Current.Response.Write("if (len>32 || pos>79) pos += dir;");
        HttpContext.Current.Response.Write("if (pos>79) len -= dir;");
        HttpContext.Current.Response.Write(" if (pos>79 && len==0) pos=0;");
        HttpContext.Current.Response.Write("elem.style.left = pos;");
        HttpContext.Current.Response.Write("elem.style.width = len;");
        HttpContext.Current.Response.Write("}}");
        HttpContext.Current.Response.Write("function remove_loading() {");
        HttpContext.Current.Response.Write(" this.clearInterval(t_id);");
        HttpContext.Current.Response.Write("var targelem = document.getElementById(‘loader_container‘);");
        HttpContext.Current.Response.Write("targelem.style.display=‘none‘;");
        HttpContext.Current.Response.Write("targelem.style.visibility=‘hidden‘;");
        HttpContext.Current.Response.Write("}");
        HttpContext.Current.Response.Write("</script>");
        HttpContext.Current.Response.Write("<div id=loader_container><img src=‘images/ajaxloader.gif‘ /></div>");
        HttpContext.Current.Response.Flush();
        }

二.加载完毕隐藏窗口,<body onload="remove_loading();">

添加样式以便于显示合理#loader_container {text-align:center; position:absolute; top:40%; width:100%; left: 0;}

页面缓冲显示正在加载图片,布布扣,bubuko.com

页面缓冲显示正在加载图片

标签:style   blog   http   java   color   os   

原文地址:http://www.cnblogs.com/xyangs/p/3860759.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!