下面是个超简单的AJAX实例:动态进度条教程,图老师小编精心挑选推荐,大家行行好,多给几个赞吧,小编吐血跪求~
【 tulaoshi.com - Web开发 】
1.建立进度条html页面
progressbar.htm
script language="javascript"
function setPgb(pgbID, pgbValue)
{
if ( pgbValue = 100 )
{
//debugger;
if (lblObj = document.getElementById(pgbID+'_label'))
{
lblObj.innerHTML = pgbValue + '%'; // change the label value
}
if ( pgbObj = document.getElementById(pgbID) )
{
var divChild = pgbObj.children[0];
pgbObj.children[0].style.width = pgbValue + "%";
}
window.status = "数据读取" + pgbValue + "%,请稍候";
}
if ( pgbValue == 100 )
{
window.status = "数据读取已经完成";
proBar.style.display="none";
Table1.style.display="none";
}
}
/script
html
head
link rel="stylesheet" type="text/css" href="common.css" /
/head
body topmargin="0" leftmargin="0"
table width="100%" height="100%" ID="Table1" runat=server
tr
td align="center" valign="middle"
DIV class="bi-loading-status" id="proBar" style="DISPLAY: ; LEFT: 425px; TOP: 278px"
DIV class="text" id="pgbMain_label" align="left"/DIV
DIV class="progress-bar" id="pgbMain" align="left"
DIV STYLE="WIDTH:10%"/DIV
/DIV
/DIV
/td
/tr
/table
/body
/html2.建立样式common.css.bi-loading-status {}{
/**//*position: absolute;*/
width: 150px;
padding: 1px;
overflow: hidden;
}
.bi-loading-status .text {}{
white-space: nowrap;
overflow: hidden;
width: 100%;
text-overflow: ellipsis;
padding: 1px;
}
.bi-loading-status .progress-bar {}{
border: 1px solid ThreeDShadow;
background: window;
height: 10px;
width: 100%;
padding: 1px;
overflow: hidden;
}
.bi-loading-status .progress-bar div {}{
background: Highlight;
overflow: hidden;
height: 100%;
filter: Alpha(Opacity=0, FinishOpacity=100, Style=1, StartX=0, StartY=0, FinishX=100, FinishY=0);
}
fixedHeader#region fixedHeader
protected string fixedHeader()
{
StringBuilder s=new StringBuilder();
s.Append(@"table width='100%' border='1' cellspacing='0' style='MARGIN-TOP:-2px'");
s.Append(@"TR class='fixedHeaderTr' style='BACKGROUND:navy;COLOR:white'");
s.Append(@"TD nowrapHeader A/TD");
s.Append(@"TD nowrapHeader B/TD");
s.Append(@"TD nowrapHeader C/TD");
s.Append(@"/TR");
for(int m=0;m100;m++)
{
s.Append(@"TR");
s.Append(@"TDA").Append(m).Append("/TD");
s.Append(@"TDB").Append(m).Append("/TD");
s.Append(@"TDC").Append(m).Append("/TD");
s.Append(@"/TR");
}
s.Append(@"/table");
return s.ToString();
}
#endregion
ThreadProc#region ThreadProc
private void ThreadProc()
{
string strScript = "scriptsetPgb('pgbMain','{0}');/script";
for ( int i = 0; i = 100; i++ )
{
System.Threading.Thread.Sleep(10);
Response.Write( string.Format( strScript, i));
Response.Flush();
}
}
#endregion
LoadData#region LoadData
private void LoadData()
{
for(int m=0;m90000;m++)
{
for(int i=0;i90000;i++)
{
}
}
}
#endregion
Web Form Designer generated code#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/**//// summary
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// /summary
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}
来源:http://www.tulaoshi.com/n/20160219/1613713.html
看过《AJAX实例:动态进度条》的人还看了以下文章 更多>>