<script>
   document.writeln("ddd");
</script>
=============================================我想在本页面输出 ddd, 为什么不行?

解决方案 »

  1.   

    页面可能还没有加载完毕<script> 
    window.onload=function(){
      document.writeln("ddd");
    }; 
    </script>
      

  2.   

    <table width="600" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#0000FF">
      <tr>
        <td colspan="4" bgcolor="#FFFFFF" class="FileHead">地震观测报告 
    <script>
             document.writeln("ddd");
             document.writeln("ddd");
             </script>
       </td>
      </tr>
    </table>请教,这样也不行,要让js执行,一般都是放到什么地方呀?还有<script> 
    window.onload=function(){
      document.writeln("ddd");
    }; 
    </script>这段代码是放在html语言里面什么地方呀?head前面吗?body里面呀?
      

  3.   

    可以的挖
    ie,ff测试均通过
    <html><head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>test</title>
    <script> 
    window.onload=function(){
      alert("onload start...");
      document.writeln("ddd");
    }; 
    </script>
    </head><body>
    <table width="600" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#0000FF"> 
      <tr> 
        <td colspan="4" bgcolor="#FFFFFF" class="FileHead">地震观测报告 
    <script> 
            alert("first write...");
            document.writeln("ddd"); 
            alert("second write...");
            document.writeln("ddd"); 
            </script> 
    </td> 
    </tr> 
    </table>
    </body></html>
      

  4.   

    <html><head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>test</title>
    </head><body>
    <table width="600" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#0000FF"> 
      <tr> 
        <td colspan="4" bgcolor="#FFFFFF" class="FileHead">地震观测报告 
    <script> 
            document.writeln("ddd"); 
            </script> 
    </td> 
    </tr> 
    </table>
    </body></html>
    可行!没有问题的!