87,918
社区成员
发帖
与我相关
我的任务
分享
<!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>
</head>
<body>
<div>
<input name="" type="text" id="cs01" style="width:500px;"/>
<input name="" type="button" value="提交"/>
</div>
<div>
<input name="" type="text" id="cs02" style="width:500px;"/>
<input name="" type="button" value="自动"/>
</div>
<script type="text/javascript">
document.getElementById("cs01").focus();
var t = "我";
var t1 = "男";
//self.setinterval的self是当前页面的意思
//var int=self.setInterval("clock()",2000)
var int=window.setInterval("clock()",2000)
function clock()
{
//var t=new Date();
document.getElementById("cs01").value=t;
if(t.length == 6)
{
//alert(6);
window.clearInterval(int);
clock01();
}
t=t+"好";
}
function clock01()
{
document.getElementById("cs02").focus();
//var int02=self.setInterval("clock02()",2000)
var int02=window.setInterval(function(){
clock02(int02);
},2000);
}
function clock02(int)
{
//alert(int);
document.getElementById("cs02").value=t1;
if(t1.length == 6)
{
window.clearInterval(int);
}
else
{
t1=t1+"女";
}
}
/*
function hello(_name){
alert("hello,"+_name);
}//*=============================================================
//* 功能: 修改 window.setInterval ,使之可以传递参数和对象参数
//* 方法: setInterval (回调函数,时间,参数1,,参数n) 参数可为对象:如数组等
//*=============================================================
//var __sto = window.setInterval;
var setInterval_l = function(callback,timeout,param){
var args = Array.prototype.slice.call(arguments,2);
var _cb = function(){
callback.apply(null,args);
}
self.setInterval(_cb,timeout);
}
setInterval_l(hello,3000,userName);
*/
</script>
</body>
</html>
<!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>
</head>
<body>
<div>
<input name="" type="text" id="cs01" style="width:500px;"/>
<input name="" type="button" value="提交"/>
</div>
<div>
<input name="" type="text" id="cs02" style="width:500px;"/>
<input name="" type="button" value="自动"/>
</div>
<script type="text/javascript">
/*
document.getElementById("cs01").focus();
var t = "我";
var t1 = "男";
//self.setinterval的self是当前页面的意思
//var int=self.setInterval("clock()",2000)
var int=window.setInterval("clock()",2000)
function clock()
{
//var t=new Date();
document.getElementById("cs01").value=t;
if(t.length == 6)
{
//alert(6);
window.clearInterval(int);
clock01();
}
t=t+"好";
}
function clock01()
{
document.getElementById("cs02").focus();
//var int02=self.setInterval("clock02()",2000)
var int02=window.setInterval(function(){
clock02(int02);
},2000);
}
function clock02(int)
{
//alert(int);
document.getElementById("cs02").value=t1;
if(t1.length == 6)
{
window.clearInterval(int);
}
else
{
t1=t1+"女";
}
}
*/
var __sto = window.setInterval;
/*
window.setInterval(function(){
alert(111);
},2000);
*/
/*
__sto(function(){
alert(111);
},2000);
*/
function hello(_name){
alert("hello,"+_name);
}
//*=============================================================
//* 功能: 修改 window.setInterval ,使之可以传递参数和对象参数
//* 方法: setInterval (回调函数,时间,参数1,,参数n) 参数可为对象:如数组等
//*=============================================================
var setIntervalParam = function(callback,timeout,param){
var args = Array.prototype.slice.call(arguments,2);
var _cb = function(){
callback.apply(null,args);
}
__sto(_cb,timeout);
}
setIntervalParam(hello,3000,"userName");
/*
*/
</script>
</body>
</html>