谢谢各位
div 中的table有数据,有好几行, 我是用XML取得的数据。
var creaObj = document.createElement;
var div = creaObj("<DIV ID='ViewDiv'style='BACKGROUND-COLOR:white; HEIGHT:"+(PageHeight-10) +"px;WIDTH:"+ (PageWidth-10)+"px;Left:200px;POSITION:relative;' ></DIV>")
var oTble = creaObj("<Table ID='ViewTable' border=1 width='"+PageWidth+"' class='HXTable'></TABLE>")
function CreateTr(objNode)
{
var oTr = creaObj("<TR></TR>");
var caption = ""
var oTd = "";
for(i=0;i<objNode.attributes.length;i++)
{
caption = objNode.attributes(i).text + " "
oTd = CreateTd(caption,i)
oTr.appendChild(oTd);
}
return oTr;
}
function CreateTd(Caption,Cell)
{
var align = "left";
var oTd = ""
if(HeadXml.childNodes[Cell].attributes(1).text=="number")
{
align="right";
}
oTd = creaObj("<TD align='"+align+"'></TD>");
oTd.innerText = Caption;
return oTd;
}
for(k=0;k<DataXml.childNodes.length;k++)
{
if(TempPageHeight<PageHeight)
{
oTr=CreateTr(DataXml.childNodes[k]);
oTable.appendChild(oTr);
}
}
oDiv.appendChild(oTable);
AllDiv.appendChild(oDiv);
大致就是这样,AllDiv 是我页面中的一个DIV,初始内容为空我用alert(AllDiv.outerHTML)可以显示出来所以有的数据。但是在页面上不显示,不知道为什么。谢谢各位