下面这个html运行时总是会出现这个提示: 
out of Memory at line:7 谁知道为什么啊?十分感谢
<html>
  <head>
    <title>How to get the selected value of a select?</title>
    <script type="text/JavaScript">
      function foo()
      {
          document.getElementById("ShowTime").innerHTML=new Date().toLocaleString();
          setInterval(foo(),100);
      }
    </script>
 </head>
 <body onload=" foo()">
   <span id="ShowTime"></span>
 </body>
<html>

解决方案 »

  1.   


    <html> 
      <head> 
        <title>How to get the selected value of a select? </title> 
        <script type="text/JavaScript"> 
    var tid;
          function foo() 
          {   clearTimeout(tid);
              document.getElementById("ShowTime").innerHTML=new Date().toLocaleString(); 
              tid= setTimeout("foo()",100); 
          } 
        </script> 
    </head> 
    <body onload="foo()"> 
      <span id="ShowTime"> </span> 
    </body> 
    <html> 
      

  2.   

    function foo() 
          { 
              document.getElementById("ShowTime").innerHTML=new Date().toLocaleString(); 
              setTimeout(foo(),100); 
          } 
    不然 出现栈超出
      

  3.   

    function foo() 
          { 
              document.getElementById("ShowTime").innerHTML=new Date().toLocaleString(); 
                    }  setInterval(foo(),100); 不然 出现栈超出  、
      

  4.   

    function foo()
    {
           document.getElementById("ShowTime").innerHTML=new Date().toLocaleString();
           setTimeout("foo()",1000); 
    }
    忘了写双引号了 "foo()"其实很简单大家想复杂了 谢谢诸位