javascript innerHTML相关例子

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>新建网页 1</title>
<script type="text/javascript">
function tbl(){
  if (t=document.getElementById("tbl1")){
    var ot = t.rows[0].cells[0]
    ot.onclick = function (){location="http://www.xxx.com"}
    ot.innerHTML = "<img scr=\"hello.jpg\" width=100 height=30>"
  }
}
window.attachEvent("onload",tbl)
</script>
</head>
<body>
<table id="tbl1" width=100% cellspacing=0 cellpadding=0 border=0>
<tr><td> </td></tr>
</table>
</body>
</html>


+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
附:修改某个标签代码片段
  var   o=document.getElementsByTagName("HTML")  
  o[0].setAttribute("xmlns:v","urn:schemas-microsoft-com:vml")

效果:<html   xmlns:v="urn:schemas-microsoft-com:vml"> 
函数里加如下语句查看:  
  alert(document.documentElement.outerHTML)

posted @ 2007-10-30 20:04  zhangsir  阅读(839)  评论(0编辑  收藏  举报