Javascript Loading Bar


Hello everyone. This code shows you that how to create a LOADING BAR with a simple trick.
This code is easy and built inn Javascript.. 
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Loading.aspx.cs" Inherits="Loading" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script language="javascript" type="text/javascript">
function widthDiv()
{
var currentWidth = parseInt(document.getElementById('result').style.width);
var maxWidth = parseInt(document.getElementById('hideAns').value);
if(currentWidth > 150)
{
document.getElementById('result').style.backgroundColor = "Yellow";
}
if(currentWidth > 250)
{
document.getElementById('result').style.backgroundColor = "Blue";
}
if(currentWidth > 400)
{
document.getElementById('result').style.backgroundColor = "Green";
}
if(currentWidth == maxWidth)
{
document.getElementById('marks').innerHTML = "80 %";
return;
}

document.getElementById('result').style.width = (currentWidth + 10) + "px";
setTimeout("widthDiv();", 50);
}

</script>
</head>
<body onload="widthDiv();">
<form id="form1" runat="server">
<div style="width:700px;">
<div id="result" style="float:left; background-color:Silver; height:20px; width:10px;">

</div>
<div id="marks"></div>
</div>
<asp:HiddenField ID="hideAns" runat="server" />
</form>
</body>
</html>
And in Code behind page.
protected void Page_Load(object sender, EventArgs e)
{
hideAns.Value = "500";
}

Comments

Popular posts from this blog

Change Css Class of li in ul onclick

Find missing sequence number. Get the numbers where sequence is missing.

Get Query String Values With Javascript