我也试试,老师指教一下
<html>
<head>
<script type="text/javascript">
function $(selector){
return document.getElementById(selector);
}
(function(){
var index = 0;
var timer = null; $.show = function (){
var d1 = $("d1"), d2 = $("d2");
timer = setInterval(loading,100);
function loading(){
if(index>=100){ clearInterval(timer); return;}
d1.style.width = ++index + "%";
d2.innerHTML = "已加载" + index + "/100";
}
}
$.end = function (){
if(timer){
clearInterval(timer);
}
}
})();
</script>
</head>
<body>
<div style="border:1px blue solid;width:800px;height:25px">
<div style="width:0px;height:23px;background-color:#FF99CC" id="d1"></div>
</div>
<div id="d2" style="font-size:9pt"> </div> <input type="button" value="开始" onclick="$.show();">
<input type="button" value="结束" onclick="$.end();">
</body>
</html>
<script type="text/javascript">
<!--
var count = 0;
var timer = 0;
function $(selector){
return document.getElementById(selector);
}
function begin(){
var ipt= $("time");
timer = setInterval(output,1);
function output(){
count++;
ipt.value = [Math.floor(count/3600),Math.floor((count%3600)/60),count%60].join(':').replace(/(^|:)(\d)(?=\D|$)/g,'$10$2');
}
}
function pause(){
if(timer) clearInterval(timer);
}
function reset(){
pause();
var ipt= $("time");
ipt.value = '00:00:00';
count = 0;
}
//-->
</script>
<body>
<input type="text" id="time" value="00:00:00"/>
<input type="button" value="开始" onClick="begin()" />
<input type="button" value="暂停" onClick="pause()" />
<input type="button" value="重置" onClick="reset()" />
</body>
<html>
<head>
<script type="text/javascript">
function $(selector){
return document.getElementById(selector);
}
(function(){
var index = 0;
var timer = null; $.show = function (){
var d1 = $("d1"), d2 = $("d2");
timer = setInterval(loading,100);
function loading(){
if(index>=100){ clearInterval(timer); return;}
d1.style.width = ++index + "%";
d2.innerHTML = "已加载" + index + "/100";
}
}
$.end = function (){
if(timer){
clearInterval(timer);
}
}
})();
</script>
</head>
<body>
<div style="border:1px blue solid;width:800px;height:25px">
<div style="width:0px;height:23px;background-color:#FF99CC" id="d1"></div>
</div>
<div id="d2" style="font-size:9pt"> </div> <input type="button" value="开始" onclick="$.show();">
<input type="button" value="结束" onclick="$.end();">
</body>
</html>
<script type="text/javascript">
<!--
var count = 0;
var timer = 0;
function $(selector){
return document.getElementById(selector);
}
function begin(){
var ipt= $("time");
timer = setInterval(output,1);
function output(){
count++;
ipt.value = [Math.floor(count/3600),Math.floor((count%3600)/60),count%60].join(':').replace(/(^|:)(\d)(?=\D|$)/g,'$10$2');
}
}
function pause(){
if(timer) clearInterval(timer);
}
function reset(){
pause();
var ipt= $("time");
ipt.value = '00:00:00';
count = 0;
}
//-->
</script>
<body>
<input type="text" id="time" value="00:00:00"/>
<input type="button" value="开始" onClick="begin()" />
<input type="button" value="暂停" onClick="pause()" />
<input type="button" value="重置" onClick="reset()" />
</body>
解决方案 »
- jquery dialog和load同时使用时报错。。。
- 如何查看某个元素用attachEvent绑定上去的事件方法
- 如何给标签中的title属性设置样式?
- javascript 中的正则表达式及||运算(高手请进)
- 全选复选框选择问题:当下面的复选框全部被选中时,全选复选框自动被选中
- js中如何随意拖动多个图片的位置,然后自动对齐
- 在线等,急,javascript的朋友帮忙啊.
- 简单问题 拿分容易!
- 用javascript把所有html标识如<td>、<table>、<html>去掉
- 如何判断输入MAIL是否符合标准格式
- 奇怪!IE7用js控制打开excel文件,开了一个新窗体后又自动关闭
- IE6下的诡异问题
我上学那会老师只会对着书狂练 没做个一个象样程序
大多程序就是 printf羡慕啊
小改^_^<html>
<head>
<script type="text/javascript">
var index = 0;
var flag=null; function show(obj){
if (!flag)
flag = window.setInterval("add()",100);
} function add() {
if(index >= 800){
window.clearInterval(flag);
}
else {
index += 4;
document.getElementById("d1").style.width = index + "px";
document.getElementById("d2").innerHTML = "已加载" + parseInt((index/800)*100) + "/100";
}
}
</script>
</head>
<body>
<div style="border:1px blue solid;width:800px;height:25px">
<div style="width:0px;height:23px;background-color:#FF99CC" id="d1"> </div>
</div>
<div id="d2" style="font-size:9pt"> </div> <input type="button" value="加载" onclick="show(this);">
</body>
</html> or:<html>
<head>
<script type="text/javascript">
var index = 0;
var flag; function show(obj){
obj.disabled=1
flag = window.setInterval("add()",100);
} function add() {
if(index >= 800)
window.clearInterval(flag);
else {
index += 4;
document.getElementById("d1").style.width = index + "px";
document.getElementById("d2").innerHTML = "已加载" + parseInt((index/800)*100) + "/100";
}
}
</script>
</head>
<body>
<div style="border:1px blue solid;width:800px;height:25px">
<div style="width:0px;height:23px;background-color:#FF99CC" id="d1"> </div>
</div>
<div id="d2" style="font-size:9pt"> </div> <input type="button" value="加载" onclick="show(this);">
</body>
</html>
小改^_^<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>新建网页 1</title>
</head><script language="javascript" type="text/javascript">
var x=0;
var y=0;
var z=0;
var aa=null;
function ontime() {
document.getElementById("time").value = x + ":"+ y + ":" + z;
if(event.srcElement.value =="暂停"){
window.clearInterval(aa);
aa=null;
}
else if(event.srcElement.value =="开始"){
if (!aa)
aa = window.setInterval(add, 10);
}
}
function add()
{
if(z < 99)
{
z=z+1;
//alert(z);
}
else if(y < 59)
{
y+=1;
z = 0;
}
else
{
x += 1;
y = 0;
z = 0;
}
document.getElementById("time").value = x + ":"+ y + ":" + z;
}
function stop()
{
window.clearInterval(aa);
}
</script>
<body>
<input type="text" value="" id="time" />
<input type="button" value="开始" onClick="ontime()" />
<input type="button" value="暂停" onClick="ontime()" />
</body> </html>