[問題] document type does not allow element …

看板Ajax作者 (***********************)時間17年前 (2008/10/09 11:36), 編輯推噓0(003)
留言3則, 1人參與, 最新討論串1/2 (看更多)
寫了一段小程式,然後用http://validator.w3.org/去作驗證, 出現「document type does not allow element "SCRIPT" here.」這個錯誤, 因為我用了一段script將資料填入table內。 想請問各位先進,這個問題是因為我的DOCTYPE不對呢? 或者是應該用其他方式將資料填入table內呢? 感謝各位看完我的問題。 --- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "" rel="nofollow">http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>TEST</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta http-equiv="Pragma" content="no-cache"> <script language="javascript" type="text/javascript"><!-- function displayData() { document.write('<tr>'); document.write('<td>AAA<\/td>'); document.write('<td>123456<\/td>'); document.write('<\/tr>'); } // --></script> </head> <body> <table border="1"> <tr> <th>Name</th> <th>ID</th> </tr> <script type="text/javascript"><!-- displayData(); // --></script> </table> </body> </html> -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 60.250.164.201 ※ 編輯: ZC 來自: 60.250.164.201 (10/09 13:53)

10/09 15:07, , 1F
可以考慮tbody給頁面table , 在onload針對tbody做元素新增:p
10/09 15:07, 1F

10/09 15:08, , 2F
簡單點的話可以採用innerHTML處理 , #18g6gSmc 這篇文章有提
10/09 15:08, 2F

10/09 15:08, , 3F
到如何針對網頁元素新增. :p
10/09 15:08, 3F
文章代碼(AID): #18xNmxbR (Ajax)
文章代碼(AID): #18xNmxbR (Ajax)