javascript 进度条 实现代码_javascript技巧
程序员文章站
2024-02-02 12:09:10
...
首先:建立两个类,一个是用来与资料进行连接(数据层),另一个是用来关联前一个类与页面的(逻辑层)
新建一个JScsrip.js 文件
代码如下:
function setPgb(pgbID, pgbValue,pvalues)
{
if ( pgbValue {
if (lblObj = document.getElementById(pgbID+'_label'))
{
lblObj.innerHTML =Math.ceil((pgbValue/pvalues)*100) + '%'; // change the label value
}
if ( pgbObj = document.getElementById(pgbID) )
{
var divChild = pgbObj.children[0];
pgbObj.children[0].style.width = Math.ceil((pgbValue/pvalues)*240);//pgbValue;
}
window.status = "数据读取第" + pgbValue+"条,请稍候";
}
if ( pgbValue == pvalues )
{
window.status = "数据读取已经完成";
proBar.style.display="none";
Table1.style.display="none";
}
}
建立一个 common.css
代码如下:
.bi-loading-status
{
/**//*position: absolute;*/
width: 250px;
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);
}
建立一个 progressbar.htm
代码如下:
建立一个 Default.aspx 文件
前台代码如下:
后台代码如下:
public partial class _Default : System.Web.UI.Page
{
DataSet ds;
text ts = new text();
int count = 0;
#region Page_Load
private void Page_Load(object sender, System.EventArgs e)
{
if (!Page.IsPostBack)
{
ds = Getgridview();
count = ds.Tables[0].Rows.Count;
Response.Write("count=" + count);
string strFileName = Server.MapPath("progressbar.htm");
StreamReader sr = new StreamReader(strFileName, System.Text.Encoding.Default);
string strHtml = sr.ReadToEnd();
Response.Write("
sr.Close();
Response.Flush();
Thread thread = new Thread(new ThreadStart(ThreadProc));
thread.Start();
LoadData(ds);
// Getgridview();
//load数据
thread.Join();
}
}
#endregion fixedHeader
#region Getgridview
protected DataSet Getgridview()
{
ds = ts.QueryProcS("2009/07", "XXXX");//这个是逻辑层中的一个方法
return ds;
}
#endregion
#region ThreadProc
private void ThreadProc()
{
string strScript = "";
for (int i = 0; i {
System.Threading.Thread.Sleep(80);
Response.Write(string.Format(strScript, i));
Response.Flush();
}
}
#endregion LoadData
#region LoadData
private void LoadData(DataSet dds)
{
for (int m = 0; m {
for (int i = 0; i {
}
}
this.GridView1.DataSource = dds.Tables[0].DefaultView;
this.GridView1.DataBind();
}
#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);
}
/**/
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
//this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}
启动加载页面时如下图所示。
加载完后会自动显示你要显示的数据。
新建一个JScsrip.js 文件
代码如下:
复制代码 代码如下:
function setPgb(pgbID, pgbValue,pvalues)
{
if ( pgbValue {
if (lblObj = document.getElementById(pgbID+'_label'))
{
lblObj.innerHTML =Math.ceil((pgbValue/pvalues)*100) + '%'; // change the label value
}
if ( pgbObj = document.getElementById(pgbID) )
{
var divChild = pgbObj.children[0];
pgbObj.children[0].style.width = Math.ceil((pgbValue/pvalues)*240);//pgbValue;
}
window.status = "数据读取第" + pgbValue+"条,请稍候";
}
if ( pgbValue == pvalues )
{
window.status = "数据读取已经完成";
proBar.style.display="none";
Table1.style.display="none";
}
}
建立一个 common.css
代码如下:
复制代码 代码如下:
.bi-loading-status
{
/**//*position: absolute;*/
width: 250px;
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);
}
建立一个 progressbar.htm
代码如下:
复制代码 代码如下:
|
建立一个 Default.aspx 文件
前台代码如下:
复制代码 代码如下:
后台代码如下:
复制代码 代码如下:
public partial class _Default : System.Web.UI.Page
{
DataSet ds;
text ts = new text();
int count = 0;
#region Page_Load
private void Page_Load(object sender, System.EventArgs e)
{
if (!Page.IsPostBack)
{
ds = Getgridview();
count = ds.Tables[0].Rows.Count;
Response.Write("count=" + count);
string strFileName = Server.MapPath("progressbar.htm");
StreamReader sr = new StreamReader(strFileName, System.Text.Encoding.Default);
string strHtml = sr.ReadToEnd();
Response.Write("
" + strHtml + "
"); sr.Close();
Response.Flush();
Thread thread = new Thread(new ThreadStart(ThreadProc));
thread.Start();
LoadData(ds);
// Getgridview();
//load数据
thread.Join();
}
}
#endregion fixedHeader
#region Getgridview
protected DataSet Getgridview()
{
ds = ts.QueryProcS("2009/07", "XXXX");//这个是逻辑层中的一个方法
return ds;
}
#endregion
#region ThreadProc
private void ThreadProc()
{
string strScript = "";
for (int i = 0; i {
System.Threading.Thread.Sleep(80);
Response.Write(string.Format(strScript, i));
Response.Flush();
}
}
#endregion LoadData
#region LoadData
private void LoadData(DataSet dds)
{
for (int m = 0; m {
for (int i = 0; i {
}
}
this.GridView1.DataSource = dds.Tables[0].DefaultView;
this.GridView1.DataBind();
}
#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);
}
/**/
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
//this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}
启动加载页面时如下图所示。
加载完后会自动显示你要显示的数据。
上一篇: php数组输出这样的json,该如何处理
下一篇: PHP实现简单的新闻发布系统实例_PHP
推荐阅读
-
javascript 进度条 实现代码_javascript技巧
-
this和执行上下文实现代码_javascript技巧
-
JavaScript中常用的运算符小结_javascript技巧
-
JS暴虐查找法简洁版_javascript技巧
-
JS中Iframe之间传值及子页面与父页面应用_javascript技巧
-
JavaScript创建命名空间(namespace)的最简实现_javascript技巧
-
javascript 判断字符串是否包含某字符串及indexOf使用示例_javascript技巧
-
JavaScript编程开发中jquery访问ashx文件示例代码
-
URL地址中的#符号使用说明_javascript技巧
-
js操作textarea 常用方法总结_javascript技巧