<script language= "javascript ">
dates();
function dates()
{
var date=new Date();
document.writeln(date.toLocaleString());
setTimeout( "dates() ",1000);
}
</script>
这里面经过刷新后为什么会出现什么对象不支持的画面?
------解决方案--------------------
<script language= "javascript ">
dates();
function dates()
{
var date=new Date();
document.writeln(date);
setTimeout( "dates ",1000);
}
</script>
------解决方案--------------------
<script language= "javascript ">
function dates()
{
var date=new Date();
document.writeln(date.toLocaleString);
setTimeout(this,1000);
}
dates();
</script>
------解决方案--------------------
不能用document.writeln,因为它对window对象有影响
<script language= "javascript ">
alert(window.dates);//得到dates函数对象
dates();
function dates()
{
var date=new Date();
document.writeln(date.toLocaleString());
alert(window.dates);//会得到 "undefined "
setTimeout( "dates() ",1000);//自然会出错
}
</script>
lz可以借助于一个控件:
<html>
<head>
<meta http-equiv= "Content-Type " content= "text/html; charset=gb2312 ">
<title> new page </title>
<script language= "javascript ">
function dates(){
var date=new Date();
document.getElementById( "date ").innerText=date.toLocaleString();
setTimeout( "dates() ",1000);
}
</script>
</head>
<body onload=dates()>
<div id=date> </div>
</body>
</html>
------解决方案--------------------
因为执行完document.writeln后,
网页会变成所输出的字符串,
如: 2007年9月18日 12:00:01
ie再执行setTimeout( "dates() ",1000);时,
已找不到dates()函数的定义