日期:2014-05-16  浏览次数:20346 次

为什么第一次显示的是NaN而不是1啊,i第一次不是赋了数值了吗,怎么不能处理啊?
<html>
<HEAD>
</HEAD>
<BODY>

<script   language=javascript>
display();
var i=1;

function   display()
{
i++;

document.write( " <html> <HEAD> </HEAD> <BODY> <p> "+document.body.clientWidth+ " </p> ");
document.writeln( " <p> "+document.body.clientHeight+ " </p> ");
document.writeln( " <p> "+document.body.scrollLeft+ " </p> ");
document.writeln( " <p> "+document.body.scrollTop+ " </p> ");
document.writeln( " <p> "+i+ " </p> </BODY> </html> ");


}
setTimeout( "display(); ",1000);


</script>
</BODY>
</html>


------解决方案--------------------
display();
var i=1;

优先级!
你那方法在变量声明前调用了...