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

这么好的重写系统alert和confirm的程序 竟然不兼容FF 谁来挽救一下它呢?
代码贴出来

Effect.js

JScript code

/**
 * 功能:显示提示窗口
 * 作者:申楠 qq:38371354 email:amushen1@yahoo.com.cn http;//amushen.cnblogs.com
 * 日期:2005-10-26
 * 版本:1.1
 * 备注:版权没有,随便拷贝,如果用于商业应用请通知本人,同时保留这段注释。
 *
 */
 /**
  * 改造:黑旋风 QQ:23929003 email:lewclear97@163.com
  * 日期:2006-03-17
  * 版本:1.2
  * 说明:本人在申楠同志的《显示提示窗口》基础上,将
  */

var alternateFrame=null;//生成的iframe
var alternateWin=null;

window.alert=showAlert;
window.confirm=showConfirm;

/**
 * 人机交互窗口,覆盖自带的
 */
function alternateWindow(){
this.win=null;//生成对话框的窗口对象
this.pBody=null;//生成的body容器对象
this.pBg=null;
this.type="alert";//默认的种类是alert
this.FocusWhere="OK";//焦点在哪个按钮上
}
/**
 * 模仿的alert窗口
 */
function showAlert(info){
alternateWin=new alternateWindow();
var pBody = alternateWin.init();
alternateWin.initAlertBody(pBody,info);
alternateWin.type="alert";
}
  /**
 * 模仿的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>")
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;
}

 /**
* 作用:初始化背景层
  */
alternateWindow.prototype.initBg=function(){
with(this.pBg.style){
position="absolute";
left="0";
top="0";
width="100%";
height="100%";
visibility="hidden";
backgroundColor="#000000";
filter="blendTrans(duration=1) alpha(opacity=30)";
}
this.pBg.filters.blendTrans.apply();
this.pBg.style.visibility="visible";
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='OK'" +
     " onkeydown='parent.alternateWin.on