想用JS做一个简单的进度条,代码及其简单,
aspx如下
<head>
<title>无标题页</title>
<script language="javascript" type="text/javascript">
//设置进度条进度
function SetPorgress(count)
{
ProgressBar.style.width= pos + "%";
}
</script>
</head>
<body>
<div id="Msg1"><font face="Verdana, Arial, Helvetica" size="2" color="#ea9b02"><b>正在加载</b></font></div>
<div id="ProgressBarSide" style="color:Silver;border-width:1px;border-style:Solid;width:300px;">
<div id="ProgressBar" style="background-color:Blue; height:21px; width:0%;"></div>
</div>
<form runat="server" id="form1">
<asp:Button ID="Button1" runat="server" Text="Button"
onclick="Button1_Click" />
</form>
</body>
</html>
.cs如下
namespace WebApplication3
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
for (int i = 1; i <= 100; i++)
{
//Response.Write("<script>SetPorgressBar(" + i + ")</script>");
Response.Flush();
ClientScript.RegisterStartupScript(ClientScript.GetType(), "Default.aspx", "<script>SetPorgressBar(" + i + ")</script>", false);
}
}
}
}
在点击按钮的时候,只执行了一次
就到1%然后就不执行了?求一个解决办法,或者一个好的创建进度条的办法!
谢绝填连接,请将详细的!