This article describes the JavaScript simulation implementation of Ajax loading box method, shared for everyone to reference. The specific methods are as follows:
Copy Code code as follows:
function loading (P_VALUE,STR)
{
if (P_value)
{
if (!document.getelementbyid ("Load_area"))
{
var para1 = document.createelement ("span");
var node=document.createtextnode (str);
Para1.appendchild (node);
var para=document.createelement ("div");
Para.id= "Load_area";
var top=document.body.scrolltop+document.documentelement.scrolltop;//gets the actual height of the page
Top_position = top+157 + "px";
Para.style.top =top_position;
Icon.style.cssText + = "; vertical-align:middle;padding-right:4px;margin-top:-2px;"
Para.style.cssText =
";p osition:absolute;left:50%;width:140px;margin-left:-70px;height:50px;line-height:50px;font-size:18px; Text-overflow:ellipsis;overflow:hidden; White-space:nowrap;text-align:center;background-color: #000; border-radius:2px;-webkit-box-shadow:0 2px 2px Rgba (0,0,0,0.5); color: #eee; ";
var icon = new Image ();
Icon.src= "Images/loading1.gif"//here Replace with actual path
Document.body.appendChild (para);
Para.appendchild (icon);
Para.appendchild (PARA1);
}
Else
{
document.getElementById ("Load_area"). style.display= "Block";
}
}
Else
{
document.getElementById ("Load_area"). style.display= "None";
}
}
The method is invoked as follows:
Copy Code code as follows:
Loading (True, "load ..."); Loading (false)
I hope this article will help you with your Web front-end programming.