<!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>
<title>动画进度条</title>
<script type="text/javascript">
var act;
function over() {
var w = document.getElementById("bar").style.pixelwidth;
if (w < 400) {
document.getElementById("bar").style.pixelWidth = w + 2;
document.getElementById("txt").innerText = "Loading..." + Math.floor(w / 400 * 100) + "%";
clearTimeout(act);
act = setTimeout(over, 10);
} else {
document.getElementById("txt").innerText = "载入完成100%";
}
function out() {
var w = parseInt(document.getElementById("bar").style.pixelWidth);
if (w > 0) {
document.getElementById("bar").style.pixelWidth = w - 2;
document.getElementById("txt").innerText = "Loading..." + Math.floor(w / 400 * 100) + "%";
clearTimeout(act);
act = setTimeout(out, 10);
} else {
document.getElementById("txt").innerText = "等待载入0%";
}
}
}
</script>
<style type="text/css">
h4
{
text-align: center;
}
#main
{
width: 400px;
height: 20px;
margin-left: auto;
margin-right: auto;
background: #eee;
border: 1px solid #333;
}
#bar
{
width: 0px;
height: 20px;
background: #eee url("Images/1.gif");
}
button
{
width: 100px;
height: 18px;
margin: 10px;
background: #eee;
border: 1px solid #333;
}
</style>
</head>
<body>
<h4 id="txt">
等待载入0%</h4>
<div id="main" onmouseover="over();" onmouseout="out();">
<div id="bar">
</div>
</div>
<button onclick="over();">
开始载入</button>
<button onclick="out();">
开始卸载</button>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>动画进度条</title>
<script type="text/javascript">
var act;
function over() {
var w = document.getElementById("bar").style.pixelwidth;
if (w < 400) {
document.getElementById("bar").style.pixelWidth = w + 2;
document.getElementById("txt").innerText = "Loading..." + Math.floor(w / 400 * 100) + "%";
clearTimeout(act);
act = setTimeout(over, 10);
} else {
document.getElementById("txt").innerText = "载入完成100%";
}
function out() {
var w = parseInt(document.getElementById("bar").style.pixelWidth);
if (w > 0) {
document.getElementById("bar").style.pixelWidth = w - 2;
document.getElementById("txt").innerText = "Loading..." + Math.floor(w / 400 * 100) + "%";
clearTimeout(act);
act = setTimeout(out, 10);
} else {
document.getElementById("txt").innerText = "等待载入0%";
}
}
}
</script>
<style type="text/css">
h4
{
text-align: center;
}
#main
{
width: 400px;
height: 20px;
margin-left: auto;
margin-right: auto;
background: #eee;
border: 1px solid #333;
}
#bar
{
width: 0px;
height: 20px;
background: #eee url("Images/1.gif");
}
button
{
width: 100px;
height: 18px;
margin: 10px;
background: #eee;
border: 1px solid #333;
}
</style>
</head>
<body>
<h4 id="txt">
等待载入0%</h4>
<div id="main" onmouseover="over();" onmouseout="out();">
<div id="bar">
</div>
</div>
<button onclick="over();">
开始载入</button>
<button onclick="out();">
开始卸载</button>
</body>
</html>
解决方案 »
- jquery 日期插件 把月 年 改成 年 月
- window.createPopup();
- 那个高手能做出来那个酷讯选择国内就显示国内城市,国际就显示国际城市求这个AJAX局部刷新代码,急求……
- JS怎么去除字符串前几位(固定),得到后几位(不固定)
- 一个关于QQ在线程序的问题,请教各位大哥拉
- easyUI 和Json
- jsp 如何动态生成js?
- http://www.pearlevision.com/ifs_files/index.htm 这个效果谁能做?什么价格.
- 发个刚写的小东西^_^
- karma(无为)!在请教一个问题!
- 新手求指点,jquery 的 galleria插件问题
- 有关“createDocumentFragment()”方法的疑惑。
http://www.codefans.net/soft/13632.shtml