日期:2014-05-16  浏览次数:20397 次

模拟JS的CONFIRM问题
代码是这样的,
//oo
function   oo(obj){
return   typeof(obj)== "string "?document.getElementById(obj):obj;
}
function   ofocu(obj){
window.tmpObj=oo(obj);
window.setTimeout( "window.tmpObj.focus() ",100);
}

function   ShowConfirm(caption){
var   l,w,h,x,y,i,n,bg,o;
w=284;
h=194;
x=(document.body.clientWidth-w)/2;
y=(document.body.clientHeight-h)/2+document.body.scrollTop;
o=document.createElement( "div ");
o.style.cssText= "display:none;z-index:99;position:absolute;left:0;top:0;width:100%;height: "+document.body.scrollHeight+ ";background:url(blank.gif) ";
o.id= "conMsg ";
document.body.appendChild(o);
l= " <div   style=cursor:default;position:absolute;left: "+x+ ";top: "+y+ ";width: "+w+ ";height: "+h+ "> ";
bg= "filter:progid:dximagetransform.microsoft.alphaimageloader(src=DBS_Images/bg_msg.png) ";
if(navigator.userAgent.indexOf( "IE   5.0 ")> 0){
bg= "background:url(DBS_Images/bg_msg.png) ";
}
if(window.Event){
bg= "background:url(DBS_Images/bg_msg.png) ";
}
l+= " <iframe   src=\ "javascript:false\ "   style=\ "position:absolute;   visibility:inherit;   top:0px;   left:0px;   width:100%;   height:100%;   z-index:-1;   border:0;   filter= 'progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0) ';\ "> </iframe> <div   style=position:absolute;width:100%;height:100%; "+bg+ "> </div> ";
l+= " <div   onselectstart=return(false)   onmousedown=this.parentNode.parentNode.drag_start(event)   align=right   style=position:absolute;height:27;width:100%;cursor:move;> ";
l+= " <button   onclick=\ "oo( 'conMsg ').style.display= 'none ';\ "   mode=10,10,3,btdlgclose   style= 'margin-top:9;margin-right:14 '> </button> </div> ";
l+= " <button   id=btDlgOk   onclick=\ "oo( 'conMsg ').style.display= 'none ';\ "   mode=72,25,3,bg_btn   style=position:absolute;left:55;top:153> 确定 </button> ";
l+= " <button   id=btDlgCel   onclick=\ "oo( 'conMsg ').style.display= 'none ';\ "   mode=72,25,3,bg_btn   style=position:absolute;left:140;top:153> 取消 </button> ";
l+= " <table   cellspadding=0   cellspacing=0   width=160   height=60   style=position:absolute;left:94;top:54;font-size:12> ";
l+= " <tr> <td   id=conMsg_caption   style=line-height:18px> &nbsp; </td> </tr> </table> ";
l+= " </div> ";
o.innerHTML=l;
ButtonRef();
o.oncontextmenu=o.onselectstart=function(){return   false}
o.onmouseup=function(){this.isDrag=null}
o.drag_start=function(e){
this.isDrag=1;
this.dragPx=this.childNodes[0].offsetLeft;
this.dragPy=this.childNodes[0].offsetTop;
this.dragSx=e.screenX;
this.dragSy=e.screenY;
}
o.onmousemove=function(e){
e=e==null?event:e;
if(this.isDrag==1){
this.childNodes[0].style.left=this.dragPx+e.screenX-this.dragSx;
this.childNodes[0].style.top=this.dragPy+e.screenY-this.dragSy;
}
}
oo( "conMsg ").style.display= " ";
oo( "conMsg_caption ").innerHTML=caption;
ofocu( "