Display simple wait information with javascript

Source: Internet
Author: User
In a Web application, a message must be displayed when some operations take a long time, prompting the user to wait. The following code is a simple javascript example. Of course, it is not a real progress bar.
Put a Label, a Button,
Then add the javascript code in a separate js file. The Code is as follows: var flag = "0 ";

Function showProcess ()
{
Window. setTimeout ('showmsg () ', 1 );
}

Function showMsg ()
{
Var msg = document. getElementById ("Label1 ");
Msg. style. color = "blue ";
If(zookeeper Doc ument. readyState! = Null&{doc ument. readyState! = 'Complete ')
{
If (flag = 0)
{
Flag = 1;
Msg. innerHTML = "Please wait .";
}
Else if (flag = 1)
{
Flag = 2;
Msg. innerHTML = "Please wait ..";
}
Else
{
Flag = 0;
Msg. innerHTML = "Please wait ...";
}
Window. setTimeout ('showmsg () ', 500 );
}
Else
{
Msg. innerHTML = "";
Flag = 0;
}
}

REFERENCE The js file on the aspx page:
<SCRIPT language = "javascript" src = "JScript. js" type = "text/Jscript"> </SCRIPT>

In the cs file of the page, add the Event code to the Button: protected void Page_Load (object sender, EventArgs e)
{
If (! IsPostBack)
{
This. Button1.Attributes. Add ("OnClick", "showProcess ();");
}
}
Protected void button#click (object sender, EventArgs e)
{
For (int I = 0; I <= 500000000; I ++)
{
}
// Response. Redirect ("werwer. aspx ");
}

Now you can run it to check the effect.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.