ASP progress bar instance

Source: Internet
Author: User

When processing data in the background, the foreground page displays the Proess Bar at the same time.
Layer is used for display.
Usage:
1. Reference
<Script language = "javascript" src = "ShowProcessBar. js"> </script>
2. Add extended attributes to the submitted Button or <A> or <span>.
IsShowProcessBar = "True"

The ShowProcessBar. js file is as follows:

AddProcessbar ();
Var bwidth = 0;
Var swidth = document. all. waiting. clientWidth;

Function CheckIsProcessBar (obj)
{
If (obj. IsShowProcessBar = "True ")
{
Return false;
}
Else
{
Return true;
}
}

Function CheckClick (e)
{
If (e = 1)
{
If (bwidth & lt; swidth * 0.98 ){
Bwidth + = (swidth-bwidth) * 0.025;
If (document. all) document. sbar. width = bwidth;
Else document. rating. clip. width = bwidth;
SetTimeout ('checkclick (1); ', 150 );

}
}
Else
{
If (document. all)
{
If (document. all. waiting. style. visibility = 'visible ')
{Document. all. waiting. style. visibility = 'den den ';
Bwidth = 1 ;}
WhichIt = event. srcElement;

While (CheckIsProcessBar (whichIt ))
{
WhichIt = whichIt. parentElement;
If (whichIt = null) return true;
}

Document. all. waiting. style. pixelTop = (document. body. offsetHeight-document. all. waiting. clientHeight)/2 + document. body. scrollTop;
Document. all. waiting. style. pixelLeft = (document. body. offsetWidth-document. all. waiting. clientWidth)/2 + document. body. scrollLeft;
Document. all. waiting. style. visibility = 'visible ';
If (! Bwidth) CheckClick (1 );
Bwidth = 1;

}

Else
{

If (document. waiting. visibility = 'show ')
{Document. waiting. visibility = 'hide ';
Document. rating. visibility = 'hide ';
Bwidth = 1 ;}
If(e.tar get. href. toString ()! = '')
{
Document. waiting. top = (window. innerHeight-document. waiting. clip. height)/2 + self. pageYOffset;
Document. waiting. left = (window. innerWidth-document. waiting. clip. width)/2 + self. pageXOffset;
Document. waiting. visibility = 'show ';
Document. rating. top = (window. innerHeight-document. waiting. clip. height)/2 + self. pageYOffset + document. waiting. clip. height-10;
Document. rating. left = (window. innerWidth-document. waiting. clip. width)/2 + self. pageXOffset;
Document. rating. visibility = 'show ';
If (! Bwidth) CheckClick (1 );
Bwidth = 1;
}
}
Return true;
}
}

Function AddProcessbar ()
{

Var Str = ""
Str + = "<div id = waiting style = position: absolute; top: 50px; left: 100px; z-index: 1; visibility: hidden> ";
Str + = "<layer name = waiting visibility = visible zIndex = 2>"
Str + = "<table border = 2 cellspacing = 1 cellpadding = 0 bordercolorlight = # FFFFFF bordercolordark = # C0C0C0 bgcolor = # E0E0E0>"
Str + = "<tr>"
Str + = "<td bgcolor = # E0E0E0 height = 30px width = 300px align = center>"
Str + = "<font color = black> the system is being processed... </font>"
Str + = "</td>"
Str + = "</tr>"
Str + = "<tr>"
Str + = "<td bgcolor = # E0E0E0>"
Str + = "Str + = "</td>"
Str + = "</tr>"
Str + = "</table>"
Str + = "</layer>"
Str + = "</div>"
Document. write (Str)

If (document. all) document. onclick = CheckClick;
}

Test File TestShowBar. HTML

<HTML>
<HEAD>
<Script language = "javascript" src = "ShowProcessBar. js"> </script>
</HEAD>
<BODY>
<A href = "error. asp" IsShowProcessBar = "True"> A Href </a>
<BR>
<BR>
<Span onclick = "location. href = 'error. asp '"style =" cursor: hand "IsShowProcessBar =" True "> <font color = blue> Span </font> </span>
<BR>
<Form action = "error. asp">
<Input type = Submit value = "Submit">
<Input type = button value = "normal button" IsShowProcessBar = "True">
</Form>
<P IsShowProcessBar = "True"> AAAAAAAAAAAAA </P>
</BODY>
</HTML>
 
 

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.