将以下内容保存在一个文件(如file.htm),它的工作原理=>打印出“3”。 但是如果我取消注释'document.write(“Hello:”);'它不再工作(输出“0”)。有人知道为什么奇怪的输出与document.links.length
<html>
<head>
<script language="JavaScript" type="text/javascript">
function display() {
//document.write("Hello: ");
document.write(document.links.length + "<br>");
}
</script>
</head>
<body onload="display()">
<A href="link0.htm">Link 0</A>
<A href="link1.htm">Link 1</A>
<A href="link2.htm">Link 2</A>
</body>
</html>
实际上是在打字!做得好 – vpram86 2010-02-17 17:20:48
差不多,不要用document.write。永远。 – Matchu 2010-02-17 17:21:23
我在IE,Firefox和Chrome上试过了。我认为你是正确的,你的解释很清楚。谢谢! – yeeen 2010-02-17 17:24:26