Ajax html中的table显示问题(IE不显示,firefox正常)

zty0527 2006-06-14 01:34:18
<!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 language="javascript">
function a()
{
}
function b()
{
}
function c()
{
}
Function.prototype.bind=function()
{
var self=this;
var arg=arguments;
return function ()
{
self.apply(null,arg);
}
}
</script>
<script type="text/javascript">
var xmlHttp;
var c="";
function createXMLHttpResponse()
{
if(window.ActiveXObject)
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");

}
else if(window.XMLHttpRequest)
{
xmlHttp=new XMLHttpRequest();
}
}
function formsubmit()
{
createXMLHttpResponse();
var url="AvatarList.aspx?UserID=52";

xmlHttp.onreadystatechange=handleStateChange;
xmlHttp.open('get',url,true);

//xmlHttp.setRequestHeader("If-Modified-Since","0");
xmlHttp.send(null);
}
function handleStateChange()
{
if(xmlHttp.readyState==4)
{

if(xmlHttp.status==200)
{
var xmlobj=xmlHttp.responseXML;
var elemDoc=xmlobj.getElementsByTagName("Avatar_table");
if(document.body.firstChild!=null)
{
document.body.removeChild(document.body.firstChild);
}

var table=document.createElement("table");
var div=document.getElementById("div1");
div.appendChild(table);
table.setAttribute("border","1");
table.setAttribute("width","50%");
table.setAttribute("cellspacing",0);
table.setAttribute("cellpadding",0);
var head=table.createTHead();
var headrow=head.insertRow(0);
headrow.insertCell(0).appendChild(document.createTextNode("ID"));
headrow.insertCell(1).appendChild(document.createTextNode("图片名"));
headrow.insertCell(2).appendChild(document.createTextNode("文件名"));

for(var i=0;i<elemDoc.length;i++) { // 循环读取
var singleCur = elemDoc[i];
row=table.insertRow(i+1);
var input=document.createElement('input');
input.type='checkbox';
var f=function(i)
{
var obj=document.getElementById("checkbox"+i);
if(obj.checked==true)
{
c=c+obj.value+",";

}
else
{

}


}
input.id="checkbox"+i;
input.value=singleCur.childNodes[0].text;
// input.value=singleCur.getElementsByTagName("AlBUM_ID")[0].firstChild.data;
input.onclick=f.bind(i);
row.insertCell(0).appendChild(input);
// row.insertCell(0).appendChild(document.createTextNode(
// singleCur.getElementsByTagName("ALBUM_ID")[0].firstChild.data));

row.insertCell(1).appendChild(document.createTextNode(
singleCur.getElementsByTagName("AVATAR_URL")[0].firstChild.data));
row.insertCell(2).appendChild(document.createTextNode(
singleCur.getElementsByTagName("AVATAR_NAME")[0].firstChild.data));
}

var Del_button=document.createElement("input");
Del_button.type="Button";
Del_button.value='删除所选个人形象';
Del_button.onclick=a;
div.appendChild(Del_button);

var Chuan_button=document.createElement("input");
Chuan_button.type="Button";
Chuan_button.value="穿所选个人形象";
Chuan_button.onclick=b;
div.appendChild(Chuan_button);

var Tuo_button=document.createElement('input');
Tuo_button.type="Button";
Tuo_button.value="脱所选个人形象";
Tuo_button.onclick=c;
document.body.appendChild(Tuo_button);
div.appendChild(Tuo_button);
}
}


}
</script>
</head>
<body onload="formsubmit()">
//这个table显示不出来
<table border="1" style="z-index: 101; left: 13px; width: 895px; position: absolute;top: 3px; display: block; height: 90px;">
<tr>
<td style="height: 84px; width: 690px;">
<label>1688Star.com</label> <a href="" ></a>
<a href="" style="z-index: 103; left: 173px; width: 35px; position: absolute;top: 10px; height: 18px">聊天</a>
<a href="" style="z-index: 104; left: 218px; position: absolute;top: 10px">好友</a>
<a href="" style="z-index: 105; left: 262px; position: absolute;top: 10px">纸条</a>
<a href="" style="z-index: 106; left: 308px; position: absolute;top: 11px">网上商城</a>
<a href="" style="z-index: 107; left: 381px; position: absolute;top: 12px">顾客中心</a>
<a href="" style="z-index: 108; left: 463px; position: absolute;top: 12px">帮助</a>
<a href="UpdatePersonal.htm" style="z-index: 109; left: 146px; position: absolute;top: 57px">个人信息修改</a>
<a href="" style="z-index: 102; left: 129px; position: absolute;top: 9px">home</a>
<a href="" style="z-index: 110; left: 255px; position: absolute;top: 57px">个人相册</a>
<a href="PersonalPicture.htm" style="z-index: 111; left: 332px; position: absolute;top: 56px"> 愿望箱</a>
<a href="" style="z-index: 112; left: 403px; position: absolute;top: 57px">账本</a>
<a href="yigui.htm" style="z-index: 113; left: 460px; position: absolute;top: 56px">衣柜</a>

</td>
</tr>
</table>
//table结束
<a href="" style="z-index: 103; left: 13px; position: absolute;top: 107px">个人信息修改</a>
<a href="" style="z-index: 104; left: 185px; position: absolute;top: 109px">个人相册</a>
<a href="" style="z-index: 105; left: 310px; position: absolute;top: 110px">愿望箱</a>
<a href="" style="z-index: 106; left: 422px; position: absolute;top: 111px">我的账本</a>
<a href="" style="z-index: 107; left: 538px; position: absolute;top: 112px">礼物信息</a>
<label style="z-index: 108; left: 11px; position: absolute;top: 143px">衣柜</label>
<label style="z-index: 109; left: 14px; position: absolute;top: 170px">亲爱的XXX,您所拥有的个人形象</label>
<div id="div1" style="z-index: 102; left: 14px; width: 607px; position: absolute; top: 206px;height: 345px"></div>

</body >
</html>
...全文
422 18 打赏 收藏 转发到动态 举报
写回复
用AI写文章
18 条回复
切换为时间正序
请发表友善的回复…
发表回复
zty0527 2006-06-14
  • 打赏
  • 举报
回复
好了,谢谢,结帖
net_boy 2006-06-14
  • 打赏
  • 举报
回复
if(document.body.firstChild!=null)
{
document.body.removeChild(document.body.firstChild);
}
你把这句去了就好了
那个tbody 是当你把从服务器读的数据添加到table时 ie不能直接添到table里 而要添到 tbody里
zty0527 2006-06-14
  • 打赏
  • 举报
回复
var Tbody=document.createElement("TBody");
var table=document.createElement("table");
var div=document.getElementById("div1");
div.appendChild(table);
div.appendChild(Tbody);
这么插入对吗?
我试验了一下,IE还是不可以
net_boy 2006-06-14
  • 打赏
  • 举报
回复
你调用AvatarList.aspx?UserID=52成功后
在这里
if(document.body.firstChild!=null)
{
document.body.removeChild(document.body.firstChild);
}
你把table给清没了当然没有了
net_boy 2006-06-14
  • 打赏
  • 举报
回复
if(document.body.firstChild!=null)
{
document.body.removeChild(document.body.firstChild);
}
你要在 它以后的脚本里 加入 tbody元素

SiaoColumn 2006-06-14
  • 打赏
  • 举报
回复
/* Create a new XMLHttpRequest object to talk to the Web server */
var xmlHttp = false;
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
try {
xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e2) {
xmlHttp = false;
}
}
@end @*/

if (!xmlHttp && typeof XMLHttpRequest != 'undefined') {
xmlHttp = new XMLHttpRequest();
}
zty0527 2006-06-14
  • 打赏
  • 举报
回复
我不加载div数据的时候显示,正常,刚才我在本地加了tbody,在IE还是显示不一样
net_boy 2006-06-14
  • 打赏
  • 举报
回复
没看到你家tbody的语句
zty0527 2006-06-14
  • 打赏
  • 举报
回复
加了,我的加注释的table不是显示不出来,就是当javascript在div1中插入表格导入数据的时候就消失了
yly19730201 2006-06-14
  • 打赏
  • 举报
回复
net_boy(小明) 说的对
Ly105 2006-06-14
  • 打赏
  • 举报
回复
net_boy(小明)正解

amandag 2006-06-14
  • 打赏
  • 举报
回复
up
net_boy 2006-06-14
  • 打赏
  • 举报
回复
做成这样大部分流行的浏览器都支持
net_boy 2006-06-14
  • 打赏
  • 举报
回复
ie不能直接将tr加在table里 你在 table里加个tbody 然后去tbody 把 tr加在tbody里
zty0527 2006-06-14
  • 打赏
  • 举报
回复
已经启用了
Knight94 2006-06-14
  • 打赏
  • 举报
回复
have a try!
如果是ie6,将你的ie设置的安全性-自定义级别-二进制脚本和行为设置为允许
zty0527 2006-06-14
  • 打赏
  • 举报
回复
我用windows 2003 怎么确定关闭了javascript教本执行
Knight94 2006-06-14
  • 打赏
  • 举报
回复
IE是否关闭了javascript脚本执行。

62,046

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧