当前位置: 首页 > 图文教程 > 网络编程 > Javascript > js loading加载效果实现代码

Javascript
有趣的script标签用getAttribute方法来自脚本吧
学习YUI.Ext 第二天
学习YUI.Ext 第三天
学习YUI.Ext第五日--做拖放Darg&Drop
学习YUI.Ext 第六天--关于树TreePanel(Part 1)
学习YUI.Ext 第七天--关于View&JSONView
学习YUI.Ext 第六天--关于树TreePanel(Part 2异步获取节点)
对YUI扩展的Gird组件 Part-2
Gird事件机制初级读本
为Yahoo! UI Extensions Grid增加内置的可编辑器
如何简单地用YUI做JavaScript动画
(function(){})()的用法与优点
JS层移支示例代码
如何在Web页面上直接打开、编辑、创建Office文档
网页中实现浏览器的最大,最小化和关闭按钮
[原创]js与自动伸缩图片 自动缩小图片的多浏览器兼容的方法总结
图片自动缩小的js代码,用以防止图片撑破页面
收藏一些不常用,但是有用的代码
解决 firefox 不支持 document.all的方法
用ajax实现的自动投票的代码

Javascript 中的 js loading加载效果实现代码


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2010-01-10   浏览: 424 ::
收藏到网摘: n/a

js loading加载效果实现代码,这个是在asp.net下的输出j代码,实现页面加载效果。
复制代码 代码如下:

protected void Page_Load(object sender, EventArgs e)
{
ShowLoading();
System.Threading.Thread.Sleep(10000);
ClientScript.RegisterClientScriptBlock(typeof(string), "", "<script>document.body.onload=function(){removeLoadMsg();}</script>");
}
/// <summary>
/// 显示页面正在加载中效果
/// </summary>
public void ShowLoading()
{
StringBuilder s = new StringBuilder();
s.Append(" <script language=JavaScript type=text/javascript>\n");
s.Append(" var t_id = setInterval(animate,20);\n");
s.Append(" var pos=0;var dir=2;var len=0;\n");
s.Append(" function animate(){\n");
s.Append(" var elem = document.getElementById('progress');\n");
s.Append(" if(elem != null) {\n");
s.Append(" if (pos==0) len += dir;\n");
s.Append(" if (len>32 || pos>79) pos += dir;\n");
s.Append(" if (pos>79) len -= dir;\n");
s.Append(" if (pos>79 && len==0) pos=0;\n");
s.Append(" elem.style.left = pos;\n");
s.Append(" elem.style.width = len;\n");
s.Append(" }}\n");
s.Append(" function removeLoadMsg() {\n");
s.Append(" this.clearInterval(t_id);\n");
s.Append(" var targelem = document.getElementById('loader_container');\n");
s.Append(" targelem.style.display='none';\n");
s.Append(" targelem.style.visibility='hidden';\n");
s.Append(" }\n ");
s.Append("</script>\n");
s.Append("<style>");
s.Append("#loader_container {text-align:center; position:absolute; top:40%; width:100%; left: 0;}\n");
s.Append("#loader {font-family:Tahoma, Helvetica, sans; font-size:11.5px; color:#000000; background-color:#FFFFFF; padding:10px 0 16px 0; margin:0 auto; display:block; width:130px; border:1px solid #5a667b; text-align:left; z-index:9999;}\n");
s.Append("#progress {height:5px; font-size:1px; width:1px; position:relative; top:1px; left:0px; background-color:#8894a8;}\n");
s.Append("#loader_bg {background-color:#e4e7eb; position:relative; top:8px; left:8px; height:7px; width:113px; font-size:1px;}\n");
s.Append("</style>\n");
s.Append("<div id=loader_container>\n");
s.Append("<div id=loader>\n");
s.Append("<div align=center>页面正在加载中...</div>\n");
s.Append("<div id=loader_bg><div id=progress> </div></div>\n");
s.Append("</div></div>\n ");
//HttpContext.Current.Response.Write(s.ToString());
HttpContext.Current.Response.Write(s.ToString());
//HttpContext.Current.Response.Flush();