Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/87.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript TypeError:未定义document.quoteform_Javascript_Html - Fatal编程技术网

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
的元素。提示:在向对象添加属性之前,对象必须存在。这让我感到困惑。所以我想一定是别的原因。我搞不懂。这就是我来论坛的原因。这更有意义。我马上就去。谢谢