关于window.setInterval()
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<script type="text/javascript">
function hello()
{
document.write(Math.random());
//alert("这是延迟后显示出来的!");
}
window.setInterval("hello()",2000);
</script>
</body>
</html>
以上代码为什么无法在每2秒后执行document.write(Math.random());的效果
但是如果如下写
function hello()
{
//document.write(Math.random());
alert("这是延迟后显示出来的!");
}
则可以达到每2秒后执行alert("这是延迟后显示出来的!");
的效果
请问高手什么原因?? HTML 函数
[解决办法]