页面打开滚动条
2006-10-11 13:17
169 查看
页面打开滚动条
建立Htm文件(文件名: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>
</html>
用到的Css文件如下(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);
}
HTML (WebForm1.aspx)代码:
<%
@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="WebApplication3.WebForm1" %>
<HTML>
<HEAD>
<title>progressbar</title>
<META http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<%=fixedHeader()%>
</form>
</body>
</HTML>
.Net 代码(WebForm1.aspx.cs):
引用如下:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Threading;
using System.IO;
using System.Text;
Page_Load事件里面代码:
Page_Load#region Page_Load
private void Page_Load(object sender, System.EventArgs e)
{
if(!Page.IsPostBack)
{
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();//load数据
thread.Join();
}
}
#endregion
其中
Thread thread = new Thread(new ThreadStart(ThreadProc));
thread.Start();
是开始线裎
调用以下方法fixedProc():
ThreadProc#region ThreadProc
private void ThreadProc()
{
string strScript = "<script>setPgb('pgbMain','{0}');</script>";
for ( int i = 0; i <= 100; i++ )
{
System.Threading.Thread.Sleep(10);
Response.Write( string.Format( strScript, i));
Response.Flush();
}
}
#endregion
WebForm1.aspx里面调用的HTML代码:
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 nowrap>Header A</TD>");
s.Append(@"<TD nowrap>Header B</TD>");
s.Append(@"<TD nowrap>Header C</TD>");
s.Append(@"</TR>");
for(int m=0;m<100;m++)
{
s.Append(@"<TR>");
s.Append(@"<TD>A").Append(m).Append("</TD>");
s.Append(@"<TD>B").Append(m).Append("</TD>");
s.Append(@"<TD>C").Append(m).Append("</TD>");
s.Append(@"</TR>");
}
s.Append(@"</table>");
return s.ToString();
}
#endregion
方法LoadData():
LoadData#region LoadData
private void LoadData()
{
for(int m=0;m<90000;m++)
{
for(int i=0;i<90000;i++)
{
}
}
}
#endregion
代码下载地址:
http://www.cnblogs.com/Files/jhtchina/progressbar.rar
建立Htm文件(文件名: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>
</html>
用到的Css文件如下(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);
}
HTML (WebForm1.aspx)代码:
<%
@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="WebApplication3.WebForm1" %>
<HTML>
<HEAD>
<title>progressbar</title>
<META http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<%=fixedHeader()%>
</form>
</body>
</HTML>
.Net 代码(WebForm1.aspx.cs):
引用如下:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Threading;
using System.IO;
using System.Text;
Page_Load事件里面代码:
Page_Load#region Page_Load
private void Page_Load(object sender, System.EventArgs e)
{
if(!Page.IsPostBack)
{
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();//load数据
thread.Join();
}
}
#endregion
其中
Thread thread = new Thread(new ThreadStart(ThreadProc));
thread.Start();
是开始线裎
调用以下方法fixedProc():
ThreadProc#region ThreadProc
private void ThreadProc()
{
string strScript = "<script>setPgb('pgbMain','{0}');</script>";
for ( int i = 0; i <= 100; i++ )
{
System.Threading.Thread.Sleep(10);
Response.Write( string.Format( strScript, i));
Response.Flush();
}
}
#endregion
WebForm1.aspx里面调用的HTML代码:
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 nowrap>Header A</TD>");
s.Append(@"<TD nowrap>Header B</TD>");
s.Append(@"<TD nowrap>Header C</TD>");
s.Append(@"</TR>");
for(int m=0;m<100;m++)
{
s.Append(@"<TR>");
s.Append(@"<TD>A").Append(m).Append("</TD>");
s.Append(@"<TD>B").Append(m).Append("</TD>");
s.Append(@"<TD>C").Append(m).Append("</TD>");
s.Append(@"</TR>");
}
s.Append(@"</table>");
return s.ToString();
}
#endregion
方法LoadData():
LoadData#region LoadData
private void LoadData()
{
for(int m=0;m<90000;m++)
{
for(int i=0;i<90000;i++)
{
}
}
}
#endregion
代码下载地址:
http://www.cnblogs.com/Files/jhtchina/progressbar.rar
相关文章推荐
- 如何实现页面打开定位滚动条的效果
- 打开页面div滚动条定位(别用锚点)
- easyui的dialog打开导致父页面出现滚动条
- 用localstorage本地存储,保存滚动条的高度下次打开页面直接跳转到滚动条处
- 使用window.showDialog打开新页面后滚动条设置
- js判断是手机端还是电脑端打开的网页页面
- 页面刷新后保持滚动条的原始位置
- JS判断页面是否出现滚动条的方法
- 几种链接总结:跳转,打开新页面,刷新当前页,不做任何操作
- 润乾——带滚动条的报表页面自适应
- 刷新父页面(window.open打开的页面)
- Javascript跳转页面和打开新窗口等方法
- 微信开发js限制页面只能在微信浏览器打开 禁止外置浏览器
- 程序内部打开某个APP在AppStore的购买页面
- html(object)控制ie的打印、刷新、另存、关闭、打开、页面设置、属性、打印预览
- 页面刷新的时候,记住滚动条的位置
- 成功安装完EASYPHP后,无法打开127.0.0.1页面的解决办法
- 点击打开另一个页面
- 打开jsp页面出现error解决办法
- zxing打开扫码页面,黑屏问题