<body> 
test2(); 
</body> 你这个该放在
<script type="text/javascript">test2(); </script> 这样吧 
或者window.onload=function(){test2(); }

解决方案 »

  1.   


    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
    <html xmlns="http://www.w3.org/1999/xhtml"> 
    <!-- saved from url=(0022)http://blog.csdn.net/electroniXtar/ --> 
    <head> 
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> 
    <title>无标题文档 </title> 
    <script type="text/javascript" src="ts2.js"> </script> 
    </head> 
    <body onload="test2();"> 
    </body> 
    </html>改成上面这样试试
      

  2.   

    或者这样
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
    <html xmlns="http://www.w3.org/1999/xhtml"> 
    <!-- saved from url=(0022)http://blog.csdn.net/electroniXtar/ --> 
    <head> 
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> 
    <title>无标题文档 </title> 
    <script type="text/javascript" src="ts2.js">
         window.onload = function(){
             test2();
         }
     </script> 
    </head> 
    <body
    </body> 
    </html>
      

  3.   

    或者这样
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
    <html xmlns="http://www.w3.org/1999/xhtml"> 
    <!-- saved from url=(0022)http://blog.csdn.net/electroniXtar/ --> 
    <head> 
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> 
    <title>无标题文档 </title> 
    <script type="text/javascript" src="ts2.js">
         window.onload = function(){
             test2();
         }
     </script> 
    </head> 
    <body
    </body> 
    </html>