JS 类的问题

shmilyhe shmilyhe 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区


<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>无标题页</title>
<style type="text/css">
.game{ width:80px;height:110px;border:1px solid #BAD1FC; background:url(hhh.gif);}
.game head{}
.game foot{}
</style>
</head>
<body>
<script type="text/jscript">
function person(id,name,x,y){
this._id=id;
this.name=name;
this._x=x;
this._y=y;
this._bl=1;
this._m=1;
}
person.prototype.getdiv =function(){

if(document.getElementById(this._id))
{
this._div=document.getElementById(this._id);
} else
{
try{
this._div=document.createElement("div");
this._div.id=this._id;
document.body.appendChild(this._div);
this._div_h=document.createElement("div");
this._div_f=document.createElement("div");
this._div.appendChild(this._div_h);
this._div.appendChild(this._div_f);
this._div.style.position="absolute";
this._div.style.top=this._y+"px";
this._div.style.left=this._x+"px";
this._div.setAttribute("class","game");
//this._div.innerHTML="success";
this._div_h.setAttribute("class","head");
this._div_f.setAttribute("class","foot");
this._div_h.innerHTML=this.name+this._id;
}catch(e){return false;}
}
}
var a= new person('eric','shmily','88','400');
a.getdiv();
</script>



</body>
</html>


在IE中只显示this._div_h.innerHTML=this.name+this._id;
的内容,在firefox中本来是能正确运行正确的(能看到背景),但我试着用JSON写完再改回来就什么也不显示了
望大侠指点一下,不胜感激
...全文

相关推荐

评论 6
收藏 已收藏
分享
返回顶部
shmilyhe
Ajax 52,778 成员 25,334 内容