Javascript TypeError:未定义document.quoteform
我的代码有一个令人讨厌的问题,我认为这是一个运行时错误,因为它在我运行程序时出现,并实际停止它。我使用了一个错误控制台来告诉我错误在哪里,但我无法理解它。如果有人能给我指出正确的方向而不给我答案,我将不胜感激。代码如下:Javascript TypeError:未定义document.quoteform,javascript,html,Javascript,Html,我的代码有一个令人讨厌的问题,我认为这是一个运行时错误,因为它在我运行程序时出现,并实际停止它。我使用了一个错误控制台来告诉我错误在哪里,但我无法理解它。如果有人能给我指出正确的方向而不给我答案,我将不胜感激。代码如下: <script type="text/javascript"> <!-- HIDE FROM INCOMPATIBLE BROWSERS function changeQuote() { quotes = new Array;
<script type="text/javascript">
<!-- HIDE FROM INCOMPATIBLE BROWSERS
function changeQuote() {
quotes = new Array;
quotes[0] = "Laughter is the best medicine.";
quotes[1] = "Never look a gift horse in the mouth.";
quotes[2] = "One good turn deserves another.";
quotes[3] = "The early bird catches the worm.";
quotes[4] = "Two is company, three is a crowd.";
var newQuote = quotes[Math.round(Math.random()+quotes.length)];
document.quoteform.quote.value = newQuote;
}
var tick = setInterval("changeQuote()");
// STOP HIDING FROM INCOMPATIBLE BROWSERS -->
</script>
</head>
<body>
<form action=""name="">
<input type="text" size="50" name="quote" /><br />
</form>
</body>
</html>
我还有两个错误控制台消息的图像:为什么要定义
document.quoteform
?我没有看到任何id或名称为quoteform
的元素。提示:在向对象添加属性之前,对象必须存在。这让我感到困惑。所以我想一定是别的原因。我搞不懂。这就是我来论坛的原因。这更有意义。我马上就去。谢谢