朋友,要明白在this实际指向谁.
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<style type="text/css" rel="sheetstyle" />
*{padding:0px;margin:0px;}
img{border:0px;}
ul{list-style:none;}
body{
text-align:center;
font-size:12px;
color:#222;
}
a:link,a:visited{text-decoration:none;color:#000;}
a:hover,a:active{text-decoration:underline;color:#8b0000;}
.bodyer{
width:840px;height:586px;
position:relative;
border-left:2px #8b0000 solid;
border-right:2px #8b0000 solid;
overflow:hidden;
margin:0px auto;
}
.button{
width:20px;height:60px;
background:#8b0000;
position:absolute;left:800px;top:40px;
padding:12px 8px;
line-height:30px;
color:#fff;
font-size:14px;
font-weight:bolder;
cursor:pointer;
}
</style>
<script language="javascript" type="text/javascript">
    var DIYViewBox=function(TitleObjId,ContObjId,ContObjH,ContObjW,ContObjL,ContObjT)
    {
        this.ContOldH=ContObjH;
        this.ContOldW=ContObjW;
        this.ContNewH=0;
        this.ContNewW=0;
        this.ContOldL=ContObjL;
        this.ContOldT=ContObjT;
        this.ContNewL=0;
        this.ContNewT=0;        
         this.TitleObj=null;
        this.ContObj=null;
        this.ISIE=document.all?true:false
        _self = this;
        function GetObj(ObjName)
        {
            if(typeof(ObjName)=="string")
            {
                if(document.getElementById){return document.getElementById(ObjName)}
                else{return document.all.ObjName}
            }
            else
            {
                return ObjName
            }
        }        
        this.AddEvent=function(EventParent,EventType,EventFun)
        {
            if(GetObj(EventParent).attachEvent)
            {GetObj(EventParent).attachEvent("on"+EventType,EventFun)}
            if(GetObj(EventParent).addEventListener)
            {GetObj(EventParent).addEventListener(EventType,EventFun,false)}
        }
        this.RemoveEvent=function(EventParent,EventType,EventFun)
        {
            if(GetObj(EventParent).detachEvent)
            {GetObj(EventParent).detachEvent("on"+EventType,EventFun)}
            if(GetObj(EventParent).removeEventListener)
            {GetObj(EventParent).removeEventListener(EventType,EventFun,false)}
        }
        this.CreateBox=function()
        {
            this.TitleObj=GetObj(TitleObjId)
            var ParentObj=this.TitleObj.parentNode;
            var CreateObj=document.createElement("div");
            CreateObj.id=ContObjId;
            CreateObj.setAttribute("id",ContObjId)
            ParentObj.appendChild(CreateObj)
            this.ContObj=GetObj(ContObjId)
            this.ContObj.style.position="absolute";
            this.ContObj.style.display="block";
            this.ContObj.style.height=this.ISIE?this.ContOldH:this.ContOldH+"px";
            this.ContObj.style.width=this.ISIE?this.ContOldW:this.ContOldW+"px";
            this.ContObj.style.left=this.ISIE?this.ContOldL:this.ContOldL+"px";
            this.ContObj.style.top=this.ISIE?this.ContOldT:this.ContOldT+"px";
            this.ContObj.style.border="#000 solid 1px"
            this.ContObj.innerHTML="danica"    
            //alert()    
            this.AddEvent(this.TitleObj,"click",this.ViewBox)                            
        }
        this.ViewBox=function()
        {        
            var DIS=(_self.ContObj.style.display="block")?true:false
            if(DIS){_self.ContObj.style.display="none"}
                        else{_self.ContObj.style.display="display"}
        }        
    }
</script>
</head>
<body>
    <div class="bodyer">
        <div class="button" id="Title">日记</div>
        <script language="javascript" type="text/javascript">
        Box1=new DIYViewBox("Title","Cont",400,400,20,40);
        Box1.CreateBox();
        </script>
    </div>
</body>
</html>