作者ZC (***********************)
看板Ajax
標題[問題] document type does not allow element "SCRIPT" here.
時間Thu Oct 9 11:36:18 2008
寫了一段小程式,然後用
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"
"
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)
1F:→ TonyQ:可以考慮tbody給頁面table , 在onload針對tbody做元素新增:p 10/09 15:07
2F:→ TonyQ:簡單點的話可以採用innerHTML處理 , #18g6gSmc 這篇文章有提 10/09 15:08
3F:→ TonyQ:到如何針對網頁元素新增. :p 10/09 15:08