没有效果啊,firefox下和遨游2下都一样啊

解决方案 »

  1.   

    改了init()
    initBg()基本不兼容alternateWindow.prototype.init=function() {
    if(alternateFrame==null){
    if(document.all) alternateFrame=document.createElement("<iframe allowTransparency='true' id='popframe' frameborder=0 marginheight=0 src='about:blank' marginwidth=0 hspace=0 vspace=0 scrolling=no></iframe>")
    else{
    alternateFrame=document.createElement("iframe");
    alternateFrame.allowTransparency='true'
    alternateFrame.id='popframe'
    alternateFrame.frameBorder='0'
    alternateFrame.marginHeight='0'
    alternateFrame.src='about:blank'
    alternateFrame.marginWidth='0'
    alternateFrame.hspace='0'
    alternateFrame.vspace='0'
    alternateFrame.scrolling='no'
    alternateFrame.name='mywin'

    }
    alternateFrame.style.position="absolute";
    document.body.appendChild(alternateFrame);
    }else{
    alternateFrame.style.visibility="visible";
    }
    alternateFrame.style.width=screen.availWidth;
    alternateFrame.style.height=screen.availHeight;
    alternateFrame.style.left=document.body.scrollLeft;
    alternateFrame.style.top=document.body.scrollTop;
    if(document.all) alternateFrame.name=alternateFrame.uniqueID;
    if(document.all) this.win=window.frames[alternateFrame.name];
    this.win = mywin;
    this.win.document.write("<body leftmargin='0' topmargin='0' oncontextmenu='self.event.returnValue=false'><div id='popbg'></div><div id='popbody'></div><div></div></body>");
    this.win.document.body.style.backgroundColor="transparent";
    document.body.style.overflow="hidden";
    if(document.all){
    this.pBody=this.win.document.body.children[1];
    this.pBg=this.win.document.body.children[0];
    }
    else{
    this.pBody=this.win.document.body.childNodes[1];
    this.pBg=this.win.document.body.childNodes[0];
    }
    this.hideAllSelect();
    this.initBg();return this.pBody;
    }
      

  2.   


    谢谢   看出来点什么了  可我把你的这段覆盖了 原来的这段
    alternateWindow.prototype.init=function() {
    if(alternateFrame==null){
    alternateFrame=document.createElement("<iframe allowTransparency='true' id='popframe' frameborder=0 marginheight=0 src='about:blank' marginwidth=0 hspace=0 vspace=0 scrolling=no></iframe>")
    alternateFrame.style.position="absolute";
    document.body.appendChild(alternateFrame);
    }else{
    alternateFrame.style.visibility="visible";
    }
    alternateFrame.style.width=screen.availWidth;
    alternateFrame.style.height=screen.availHeight;
    alternateFrame.style.left=document.body.scrollLeft;
    alternateFrame.style.top=document.body.scrollTop;
    alternateFrame.name=alternateFrame.uniqueID;this.win=window.frames[alternateFrame.name];
    this.win.document.write("<body leftmargin=0 topmargin=0 oncontextmenu='self.event.returnValue=false'><div id=popbg></div><div id=popbody></div><div></div></body>");
    this.win.document.body.style.backgroundColor="transparent";
    document.body.style.overflow="hidden";
    this.pBody=this.win.document.body.children[1];
    this.pBg=this.win.document.body.children[0];
    this.hideAllSelect();
    this.initBg();return this.pBody;
    }
    怎么在显示上有问题呀?麻烦给解释一下  谢谢
      

  3.   


    只是想让FF能够支持  现在FF下好像不兼容 呵
      

  4.   

    FF 不认with吗?with不够标准?
      

  5.   

    建议再加入一个JS使用IE和FF接近http://blog.csdn.net/rjzou2006/archive/2008/03/31/2232293.aspx不行再给我发信息。
      

  6.   

    <!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>
    <script>
    function clk_yes()
    {
        alert("哈哈哈");
    }function clk_no()
    {
        alert("哈哈哈1111");
    }
    var alternateFrame=null;//生成的iframe
    var alternateWin=null;
    window.alert=showAlert;
    window.confirm=showConfirm;
    var IsIE=document.all;function alternateWindow(){
    this.win=null;//生成对话框的窗口对象
    this.pBody=null;//生成的body容器对象
    this.pBg=null;
    this.type="alert";//默认的种类是alert
    this.FocusWhere="OK";//焦点在哪个按钮上
    }function showAlert(info){
    alternateWin=new alternateWindow();
    var pBody = alternateWin.init();
    alternateWin.initAlertBody(pBody,info);
    alternateWin.type="alert";
    }function showConfirm(info,ok_func,notok_func,ok_str,not_okstr){
    alternateWin=new alternateWindow();
    var pBody = alternateWin.init();
    alternateWin.initConfirmBody(pBody,info,ok_func,notok_func,ok_str,not_okstr);
    alternateWin.type="confirm";
    }alternateWindow.prototype.init=function() {
    if(alternateFrame==null){
    /*alternateFrame=document.createElement("<iframe allowTransparency='true' id='popframe' "
    +"frameborder=0 marginheight=0 src='about:blank' marginwidth=0 hspace=0 vspace=0 scrolling=no></iframe>")*/
    //上面的ff不能兼容
    alternateFrame=document.createElement("iframe");
    //alternateFrame.allowTransparency='true';//这个没有什么用啊...........
    alternateFrame.id='popframe';
    alternateFrame.frameborder=0;
    alternateFrame.marginheight=0;
    alternateFrame.vspace=0;
    alternateFrame.hspace=0;
    alternateFrame.scrolling="no";
    alternateFrame.src='about:blank';
    alternateFrame.style.position="absolute";
    document.body.appendChild(alternateFrame);
    }else{
    alternateFrame.style.visibility="visible";
    }
    //ff设置位置时要把单位加上
    alternateFrame.style.width=screen.availWidth+"px";
    alternateFrame.style.height=screen.availHeight+"px";
    alternateFrame.style.left=document.body.scrollLeft+"px";
    alternateFrame.style.top=document.body.scrollTop+"px";
    //alternateFrame.name=alternateFrame.uniqueID;//ff下iframe不支持uniqueID属性
    alternateFrame.name="popframe";
    //this.win=window.frames[alternateFrame.name];//=========
    this.win=IsIE?window.frames[alternateFrame.name]:document.getElementById("popframe").contentWindow;
    this.win.document.write("<body leftmargin=0 topmargin=0 oncontextmenu='self.event.returnValue=false'><div id=popbg></div><div id=popbody></div><div></div></body>");
    this.win.document.body.style.backgroundColor="transparent";
    document.body.style.overflow="hidden";
    //=============下面两句
    this.pBody=IsIE?this.win.document.body.children[1]:this.win.document.getElementById("popbody");
    this.pBg=IsIE?this.win.document.body.children[0]:this.win.document.getElementById("popbg");
    this.hideAllSelect();
    this.initBg();
    return this.pBody;
    } /**
    * 作用:初始化背景层
      */
      //=============ff的滤镜播放效果的支持知道怎么搞
    alternateWindow.prototype.initBg=function(){
    with(this.pBg.style){
    position="absolute";
    left="0";
    top="0";
    width="100%";
    height="100%";
    visibility="hidden";
    backgroundColor="#000000";
    if(IsIE)
     filter="blendTrans(duration=1) alpha(opacity=30)";//==========
    else//ff下的blendTrans滤镜好象不支持,反正是不知道了
      opacity="0.3";//透明度这样设置,是ff时  
    }
    if(IsIE) this.pBg.filters.blendTrans.apply();
    this.pBg.style.visibility="visible";
    if(IsIE) this.pBg.filters.blendTrans.play();
    }
    /**
     * 作用:初始化显示层
     */
    alternateWindow.prototype.initAlertBody=function(obj,info){
    with(obj.style){
    position="absolute";
    width="400";
    height="150";
    backgroundColor="#ffffff";
    }
    obj.style.left=window.document.body.clientWidth/2-200;
    obj.style.top=window.document.body.clientHeight/10;
    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:#e1dfdf;font-size:14px;font-weight:bold' bgcolor=#454545>【新闻详细】<span id=newstitle></span></td></tr>";
    str+="<tr><td align=center bgcolor=#e1dfdf style='font-size:12px;color:#454545;vertical-align: top;padding-top:5px;'>";
    str+=info+"</td></tr><tr height=40 bgcolor=#cccccc><td align=center>" +
         "<input type='button' value='关 闭' id='AlertOK'" +//这里id要注意唯一
         " onkeydown='parent.alternateWin.onKeyDown(event,this)'"+
         " onclick='parent.alternateWin.closeWin()' style='border:solid 1px #797979;background:#f8f8f8;width:80px; padding:3px;'>" +
         "</td></tr></table>";
    obj.innerHTML=str;
    //这句话有问题,ff不支持all
    if(IsIE)this.win.document.body.all.AlertOK.focus();else this.win.document.getElementById("AlertOK");
    this.FocusWhere="OK";
    }
    alternateWindow.prototype.onKeyDown=function(event,obj){
      switch(event.keyCode){
      case 9://tab键
      //这里事件对象属性和方法使用没加与区别
      if(IsIE) event.keyCode=-1;else event.preventDefault();
      if(this.type=="confirm"){
      if(this.FocusWhere=="OK"){
      if(IsIE)
        this.win.document.body.all.ConfirmNO.focus();
      else
        this.win.document.getElementById("ConfirmNo").focus();
      this.FocusWhere="NO";
      }else{
      if(IsIE)this.win.document.body.all.ConfirmOK.focus();else this.win.document.getElementById("ConfirmOK").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='ConfirmOK'" +//这里id要注意唯一
    " 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='ConfirmNO'"+//这里id要注意唯一
    " 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;
    if(IsIE)this.win.document.body.all.ConfirmOK.focus();else this.win.document.getElementById("ConfirmOK").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>
    </head><body>
     <font color='red'>此功能由ShowBo,from CSDN修改于2008-4-11,兼容了ff2.0(滤镜过渡效果不知道搞),IE6.0,其他浏览器没测试<br />
     
     我个人觉得这个没多大意义,不能挂起线程,当加入form中时更本就没意思。</font><br /><br /><br />
     
     
    <h1>下面这个没放到表单中,可以见到效果</h1><br />
    <input name="" type="submit" onclick="return confirm('今天天气真的很好啊,难道不是么?','clk_yes','clk_no','就算是吧','乱讲');" />
    <form>
    <h1>下面这个放到表单中,挂不起线程,根本没意思</h1><br />
    <input name="" type="submit" onclick="return confirm('今天天气真的很好啊,难道不是么?','clk_yes','clk_no','就算是吧','乱讲');" /></form>
    </html>
      

  7.   

    很强大  谢谢了~  就要这样的答案   感谢两位高手  特别是showbo的详细解说   结帖了