<!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>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>无标题文档</title>
<style>
#loading{
width:500px;
height:40px;
border:1px solid blue;
margin:100px auto 0 auto;
text-align:center;
line-height:40px;
background:#FFCCFF;
}
#in{
height:40px;
width:0px;
margin:0px;
background:#CCFFCC;
float:left;
text-align:center;
}
#txt{
width:500px;
height:25px;
margin:0 auto 0 auto;
text-align:center;
}
</style>
</body>
</head><body>
<div id="loading">
<div id="in" style="width:0px"></div>
</div>
<div id="txt"></div>
<script>
var str = 0;
var sty=document.getElementById("in").style.width;
//alert(sty);
function myload(){
str = str + 10;
if (str>=110)
{
alert("加载完成!");
return false;
}
document.getElementById("txt").innerHTML = str + "%";
sty = parseInt(sty)+50;
document.getElementById("in").style.width=sty.toString() + "px";
setTimeout("myload()",500);
}
myload();
</script>
</html>这是我写的js进度条,有两点问题,一、怎么使那个 % 放在框框里面。二、代码太长了,又没有简单速度快的代码?
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>无标题文档</title>
<style>
#loading{
width:500px;
height:40px;
border:1px solid blue;
margin:100px auto 0 auto;
text-align:center;
line-height:40px;
background:#FFCCFF;
}
#in{
height:40px;
width:0px;
margin:0px;
background:#CCFFCC;
float:left;
text-align:center;
}
#txt{
width:500px;
height:25px;
margin:0 auto 0 auto;
text-align:center;
}
</style>
</body>
</head><body>
<div id="loading">
<div id="in" style="width:0px"></div>
</div>
<div id="txt"></div>
<script>
var str = 0;
var sty=document.getElementById("in").style.width;
//alert(sty);
function myload(){
str = str + 10;
if (str>=110)
{
alert("加载完成!");
return false;
}
document.getElementById("txt").innerHTML = str + "%";
sty = parseInt(sty)+50;
document.getElementById("in").style.width=sty.toString() + "px";
setTimeout("myload()",500);
}
myload();
</script>
</html>这是我写的js进度条,有两点问题,一、怎么使那个 % 放在框框里面。二、代码太长了,又没有简单速度快的代码?
解决方案 »
- xmlhttp发送数据问题请教
- 急求一正则表达式
- 写一个HTML页面,实现以下功能,左键点击页面时显示“您好”,右键点击时显示“禁止右键”。并在2分钟后自动关闭页面
- 请问js在new ActiveXObject对象时,如果ActiveX被禁用,我如何得知我的ActiveXObject被成功生成或者没有new出来
- JS 通过图片ur地址 获取图片大小,不能加 onload,不支持IE7
- 几个属性和方法的使用
- javascript的问题
- 用js如何获取url参数如下地址http://book.gobygo.com/TheGoByGoWebForUser/Category/Book/BookProductLibraryHome.htm?url=http://book.g
- applet中怎么<marquee>不可以用?
- 急求弹出查询的解决方案,要不然国庆节后期都没有玩了,呜呜呜
- JavaScript变量的问题
- 请教如何把数组里面的数转换成 数字。
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>无标题文档</title>
<style>
#loading{
width:500px;
height:40px;
border:1px solid blue;
margin:100px auto 0 auto;
text-align:center;
line-height:40px;
background:#FFCCFF;
position:relative;
}
#in{
height:40px;
width:0px;
margin:0px;
background:#CCFFCC;
float:left;
text-align:center;
}
#txt{
position:absolute;
left:250px;
top:10px;
margin:0 auto 0 auto;
text-align:center;
}
</style></body>
</head><body>
<div id="loading">
<div id="txt">dd</div>
<div id="in" style="width:0px"></div>
</div> <script>
var str = 0;
var sty=document.getElementById("in").style.width;
//alert(sty);
function myload(){
str = str + 1;
if (str>=101)
{
alert("加载完成");
return false;
}
document.getElementById("txt").innerHTML = str + "%";
sty = parseInt(sty)+5;
document.getElementById("in").style.width=sty.toString() + "px";
setTimeout("myload()",50);
}
myload();
</script>
</html>