<!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">
<head>
    <title></title>
    <script type="text/javascript">
        window.onload = function () {
            var oDiv = document.getElementById("div1");
            var table = document.createElement("table");
            oDiv.appendChild(table);
            var tr = document.createElement("tr");
            table.appendChild(tr);
            var td = document.createElement("td");
            tr.appendChild(td);
            var p = document.createTextNode("hello,world");
            td.appendChild(p);
            td = document.createElement("td");
            tr.appendChild(td);
        }
    
    </script></head>
<body>
<div id="div1"></div></body>
</html>这个Hello world出不来。。

解决方案 »

  1.   

    加上编码是什么意思? 怎么加?我用ie9出不来,用chrome能出来。。
      

  2.   

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    加上这句,保存的时候选utf-8无bom格式
      

  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">
    <head>
        <title></title>
        <script type="text/javascript">
            window.onload = function () {
                var oDiv = document.getElementById("div1");
                var table = document.createElement("table");
                oDiv.appendChild(table);
    var tbody = document.createElement("tbody");
    table.appendChild(tbody);
                var tr = document.createElement("tr");
                tbody.appendChild(tr);
                var td = document.createElement("td");
                tr.appendChild(td);
                var p = document.createTextNode("hello,world");
                td.appendChild(p);
                td = document.createElement("td");
                tr.appendChild(td);
            }
        
        </script></head>
    <body>
    <div id="div1"></div></body>
    </html>