javascript 简易计时器
<script language="javascript">
var timeLen = "0";
var timer = null;
function beginTimer()
{
var hour="0";
var minute="0";
var second="0";
timeLen = parseInt(timeLen)+1;
hour = parseInt(timeLen/3600) ;
minute = parseInt((timeLen-(hour*3600))/60);
second = parseInt((timeLen-(minute*60))%60);
//document.frmtimer.time.innerText = hour+"时"+minute+"分"+second+"秒";
document.getElementById("time").innerText=hour+"时"+minute+"分"+second+"秒";
timer = setTimeout("beginTimer()",1000);
document.getElementById("startButton").disabled = true;
document.getElementById("stopButton").disabled = false;
}
function stopTimer()
{
clearTimeout(timer);
document.getElementById("startButton").disabled = false;
document.getElementById("stopButton").disabled = true;
}
</script>
<html>
<head>
<title>简易计时器</title>
</head>
<body>
<form name="frmtimer" action="" method="post">
<hr>
<input type="text" name="time" id="time">
<br>
<input type="button" value="开始计时" name="start" id="startButton" onClick="beginTimer();">
<input type="button" value="停止" name="stop" id="stopButton" onClick="stopTimer();">
<hr>
</form>
</body>
</html>
相关文档:
scrollHeight: 获取对象的滚动高度。
scrollLeft:设置或获取位于对象左边界和窗口中目前可见内容的最左端之间的距离
scrollTop:设置或获取位于对象最顶端和窗口中可见内容的最顶端之间的距离
scrollWidth:获取对象的滚动宽度
offsetHeight:获取对象相对于版面或由父坐标 offsetParent 属性指定的父坐标的高度
offsetL ......
1.substring 方法
定义和用法
substring 方法用于提取字符串中介于两个指定下标之间的字符。
语法
stringObject.substring(start,stop)
参数 描述
start 必需。一个非负的整数,规定要提取的子串的第一个字符在 stringObject 中的位置。
stop 可选。一个非负的整数,比要提取的子串的最后一个字符 ......
JS的正则表达式
//校验是否全由数字组成
function isDigit(s)
{
var patrn=/^[0-9]{1,20}$/;
if (!patrn.exec(s)) return false
return true
}
//校验登录名:只能输入5-20个以字母开头、可带数字、“_”、“.”的字串
Java代码
function isRegisterUserName(s) &n ......
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!-- saved from url=(0041)/ -->
<html xmlns="http://www.w3.org/1999/xhtml">
<HEAD>
<TITLE>JavaScript仿Excel表格演示- /</TITLE>
< ......
1. oncontextmenu="window.event.returnValue=false" 将彻底屏蔽鼠标右键
<table border oncontextmenu=return(false)><td>no</table> 可用于Table
2. <body onselectstart="return false"> 取消选取、防止复制
3. onpaste="return false" 不准粘贴
4. oncopy="return false;" oncut="re ......