alternateWindow.prototype.onKeyDown=function(event,obj){
   switch(event.keyCode){
   case 9:
     event.keyCode=-1;
   if(this.type=="confirm"){
   if(this.FocusWhere=="OK"){
   this.win.document.body.all.NO.focus();
   this.FocusWhere="NO";
   }else{
   this.win.document.body.all.OK.focus();
   this.FocusWhere="OK";
   }
   }
   break;
   case 13:obj.click();;break ;
   case 27:this.closeWin();break ;  
   }  }
/**
 * 作用:初始化显示层 conFirm提示层
 */
alternateWindow.prototype.initConfirmBody=function(obj,info,ok_func,notok_func,ok_str,notok_str){
with(obj.style){
position="absolute";
width="400";
height="150";
backgroundColor="#ffffff";
}
if(ok_str==null){
ok_str="确定";
}
if(notok_str==null){
notok_str="取消"
}
obj.style.left=window.document.body.clientWidth/2-200;
obj.style.top=window.document.body.clientHeight/3;
var str;
str="<table border=0 cellpadding=0 cellspacing=1 bgcolor=#000000 width=100% height=100%><tr height=30>";
str+="<td align=left style='color:#000000;font-size:14px;font-weight:bold' bgcolor=#9999ff>[询问]</td></tr>";
str+="<tr><td align=center bgcolor=#efefff style='font-size:12px;color:#000000;vertical-align: middle;'>";
str+=info+"</td></tr><tr height=30 bgcolor=#efefef><td align=center>" +
"<input type='button' id='OK'" +
" onkeydown='parent.alternateWin.onKeyDown(event,this)'"+
" onclick='parent.alternateWin.closeWin();parent."+ok_func+"();' " +
" value='"+ok_str+"' style='border:solid 1px #666666;background:#cccccc'>"+
"&nbsp;&nbsp;&nbsp;<input type='button' value='"+notok_str+"' id='NO'"+
" onkeydown='parent.alternateWin.onKeyDown(event,this)'"+
" onclick='parent.alternateWin.closeWin();" +
" parent."+notok_func+"();' style='border:solid 1px #666666;background:#cccccc'></td></tr></table>";
obj.innerHTML=str;
this.win.document.body.all.OK.focus();
} /**
 * 作用:关闭一切
 */
alternateWindow.prototype.closeWin=function(){
alternateFrame.style.visibility="hidden";  
this.showAllSelect();
document.body.style.overflow="auto";  
}
/**
  * 作用:隐藏所有的select
  */
alternateWindow.prototype.hideAllSelect=function(){
  var obj;
  obj=document.getElementsByTagName("SELECT");
  var i;
  for(i=0;i<obj.length;i++)
obj[i].style.visibility="hidden";
  }
/**
 * 显示所有的select
 */  
  alternateWindow.prototype.showAllSelect=function(){
  var obj;
  obj=document.getElementsByTagName("SELECT");
  var i;
  for(i=0;i<obj.length;i++)
obj[i].style.visibility="visible";
}
</script><!---------------------------------------------------------------->
<script>
function clk_yes(){
alert("你也同意了我的观点");
}
function clk_no(){
alert("不是你眼花了就是我眼花了!");
}</script>

解决方案 »

  1.   

    alternateWindow.prototype.onKeyDown=function(event,obj){
       switch(event.keyCode){
       case 9:
         event.keyCode=-1;
       if(this.type=="confirm"){
       if(this.FocusWhere=="OK"){
       this.win.document.body.all.NO.focus();
       this.FocusWhere="NO";
       }else{
       this.win.document.body.all.OK.focus();
       this.FocusWhere="OK";
       }
       }
       break;
       case 13:obj.click();;break ;
       case 27:this.closeWin();break ;  
       }  }
    /**
     * 作用:初始化显示层 conFirm提示层
     */
    alternateWindow.prototype.initConfirmBody=function(obj,info,ok_func,notok_func,ok_str,notok_str){
    with(obj.style){
    position="absolute";
    width="400";
    height="150";
    backgroundColor="#ffffff";
    }
    if(ok_str==null){
    ok_str="确定";
    }
    if(notok_str==null){
    notok_str="取消"
    }
    obj.style.left=window.document.body.clientWidth/2-200;
    obj.style.top=window.document.body.clientHeight/3;
    var str;
    str="<table border=0 cellpadding=0 cellspacing=1 bgcolor=#000000 width=100% height=100%><tr height=30>";
    str+="<td align=left style='color:#000000;font-size:14px;font-weight:bold' bgcolor=#9999ff>[询问]</td></tr>";
    str+="<tr><td align=center bgcolor=#efefff style='font-size:12px;color:#000000;vertical-align: middle;'>";
    str+=info+"</td></tr><tr height=30 bgcolor=#efefef><td align=center>" +
    "<input type='button' id='OK'" +
    " onkeydown='parent.alternateWin.onKeyDown(event,this)'"+
    " onclick='parent.alternateWin.closeWin();parent."+ok_func+"();' " +
    " value='"+ok_str+"' style='border:solid 1px #666666;background:#cccccc'>"+
    "&nbsp;&nbsp;&nbsp;<input type='button' value='"+notok_str+"' id='NO'"+
    " onkeydown='parent.alternateWin.onKeyDown(event,this)'"+
    " onclick='parent.alternateWin.closeWin();" +
    " parent."+notok_func+"();' style='border:solid 1px #666666;background:#cccccc'></td></tr></table>";
    obj.innerHTML=str;
    this.win.document.body.all.OK.focus();
    } /**
     * 作用:关闭一切
     */
    alternateWindow.prototype.closeWin=function(){
    alternateFrame.style.visibility="hidden";  
    this.showAllSelect();
    document.body.style.overflow="auto";  
    }
    /**
      * 作用:隐藏所有的select
      */
    alternateWindow.prototype.hideAllSelect=function(){
      var obj;
      obj=document.getElementsByTagName("SELECT");
      var i;
      for(i=0;i<obj.length;i++)
    obj[i].style.visibility="hidden";
      }
    /**
     * 显示所有的select
     */  
      alternateWindow.prototype.showAllSelect=function(){
      var obj;
      obj=document.getElementsByTagName("SELECT");
      var i;
      for(i=0;i<obj.length;i++)
    obj[i].style.visibility="visible";
    }
    </script><!---------------------------------------------------------------->
    <script>
    function clk_yes(){
    alert("你也同意了我的观点");
    }
    function clk_no(){
    alert("不是你眼花了就是我眼花了!");
    }</script>
      

  2.   

    我晕了,网速太慢,整个程序分3段发的,中间一段发了2次!不好意思,3段按顺序保存成htm就可以了.谢谢!
      

  3.   

    呵呵,经过实验,其实这东西并不是很实用,至少真实alert的模态性不能够满足,只能用在少量地方.所以我决定用showModalDialog重新做一个算了,丑一点是丑一点,但是功能第一啊,大家说是吧?
      

  4.   

    看看它的吧http://www.uselesspickles.com/jsballs/