友好的提示窗口,模仿网易邮箱的提示窗。
主要修改:
1、增加了打开的音效,不过声音文件选择的不好。
2、修改了界面
3、增加了询问窗口,可以响应主页面的函数。(主要功能)
下载地址:
https://files.cnblogs.com/amushen/popAlert_1.1.rar
代码:
1
// JavaScript Document2

/**//**3
* 功能:显示提示窗口4
* 作者:申楠 qq:38371354 email:amushen1@yahoo.com.cn http;//amushen.cnblogs.com5
* 日期:2005-10-266
* 版本:1.1 7
* 备注:版权没有,随便拷贝,如果用于商业应用请通知本人,同时保留这段注释。8
* 9
*/10

11

/**//**12
* 描述:显示提示层13
* 作者:申楠14
* 参数: 显示信息内容15
* 返回: 无16
* 日期:2005-10-2517
*/18
var ifm=null;19

function showAlert(info)
{20
var pBody;21
pBody=init(); 22
initAlertBody(pBody,info); 23
pBody.focus(); 24
}25

function showConfirm(info,_yes,_no)
{26
var pBody;27
pBody=init();28
initConfirmBody(pBody,info,_yes,_no);29
pBody.focus();30
}31

/**//**32
* 描述:初始基本信息33
* 作者:申楠34
* 参数: 无35
* 返回: 内容层36
* 日期:2005-10-2537
*/38

39

function init()
{40

if(ifm==null)
{41
ifm=document.createElement("<iframe allowTransparency='true' id='popframe' frameborder=0 marginheight=0 src='about:blank' marginwidth=0 hspace=0 vspace=0 scrolling=no></iframe>")42
ifm.style.width=screen.availWidth;43
ifm.style.height=screen.availHeight;44
ifm.style.position="absolute";45
ifm.style.left=0;46
ifm.style.top=0;47
ifm.name=ifm.uniqueID;48
document.body.appendChild(ifm); 49

}else
{50
ifm.style.visibility="visible";51
}var win=window.frames[ifm.name];52
win.document.write("<body leftmargin=0 topmargin=0 oncontextmenu='self.event.returnValue=false'><div id=popbg></div><div id=popbody></div><div></div></body>");53
win.document.body.style.backgroundColor="transparent";54
55
document.body.style.overflow="hidden";56
57
var pBody=win.document.body.children[1];58
var pBg=win.document.body.children[0]; 59
var pSnd=win.document.body.children[2];60
61
hideAllSelect();62
initSnd(pSnd);63
initBg(pBg);64
return pBody;65
}66
67

/**//**68
* 描述:初始音效69
* 作者:申楠70
* 参数: obj;音效层71
* 返回: 无72
* 日期:2005-10-2573
*/74

function initSnd(obj)
{ 75
obj.innerHTML='<embed src="snd.mp3" loop="false" autostart="true" hidden=true></embed>';76
}77
78

/**//**79
* 描述:初始化背景层80
* 作者:申楠81
* 参数: obj;背景层82
* 返回: 无83
* 日期:2005-10-2584
*/85

function initBg(obj)
{86

with(obj.style)
{87
position="absolute"; 88
left="0";89
top="0";90
width="100%";91
height="100%";92
visibility="hidden";93
backgroundColor="#333333";94
filter="blendTrans(duration=1) alpha(opacity=60)";95
}96
97

if (obj.filters.blendTrans.status != 2)
{//no playing98
obj.filters.blendTrans.apply();99
obj.style.visibility="visible";100
obj.filters.blendTrans.play();101
}102

103

104
}105

/**//**106
* 描述:初始化显示层107
* 作者:申楠108
* 参数: obj;显示层;info:显示内容;109
* 返回: 无110
* 日期:2005-10-25111
*/112

function initAlertBody(obj,info)
{113

with(obj.style)
{114
position="absolute";115
width="400";116
height="150";117
backgroundColor="#ffffff"; 118
}119
obj.style.left=window.document.body.clientWidth/2-200;120
obj.style.top=window.document.body.clientHeight/3;121
var str;122
str="<table border=0 cellpadding=0 cellspacing=1 bgcolor=#000000 width=100% height=100%><tr height=30>";123
str+="<td align=left style='color:#000000;font-size:14px;font-weight:bold' bgcolor=#9999ff>[提示]</td></tr>";124
str+="<tr><td align=center bgcolor=#efefff style='font-size:12px;color:#000000;vertical-align: middle;'>";125
str+=info+"</td></tr><tr height=30 bgcolor=#efefef><td align=center><button onclick='parent.closeWin()' style='border:solid 1px #666666;background:#cccccc'>确定</button></td></tr></table>";126
obj.innerHTML=str;127
}128

129

/**//**130
* 描述:初始化显示层 conFirm提示层131
* 作者:申楠132
* 参数: obj;显示层;info:显示内容;_yes:click ok to trig;_no:click no to trig133
* 返回: 无134
* 日期:2005-10-25135
*/136

function initConfirmBody(obj,info,_yes,_no)
{137

with(obj.style)
{138
position="absolute";139
width="400";140
height="150";141
backgroundColor="#ffffff"; 142
}143
obj.style.left=window.document.body.clientWidth/2-200;144
obj.style.top=window.document.body.clientHeight/3;145
var str;146
str="<table border=0 cellpadding=0 cellspacing=1 bgcolor=#000000 width=100% height=100%><tr height=30>";147
str+="<td align=left style='color:#000000;font-size:14px;font-weight:bold' bgcolor=#9999ff>[询问]</td></tr>";148
str+="<tr><td align=center bgcolor=#efefff style='font-size:12px;color:#000000;vertical-align: middle;'>";149
str+=info+"</td></tr><tr height=30 bgcolor=#efefef><td align=center><button style='width:40px' onclick='parent.closeWin();parent."+_yes+"();' style='border:solid 1px #666666;background:#cccccc'>是</button> <button style='width:40px' onclick='parent.closeWin();parent."+_no+"();' style='border:solid 1px #666666;background:#cccccc'>否</button></td></tr></table>";150
obj.innerHTML=str;151
}152

153

/**//**154
* 描述:关闭一切155
* 作者:申楠156
* 参数: obj :the iframe 's name 157
* 返回: 无158
* 日期:2005-10-25159
*/160

function closeWin()
{161
ifm.style.visibility="hidden"; 162
showAllSelect();163
document.body.style.overflow="auto"; 164
}165

/**//**166
* describe:hide all select167
* author:shennan168
* params:169
* return:170
* date:2005-10-25171
*/172

function hideAllSelect()
{173
var obj;174
obj=document.getElementsByTagName("SELECT");175
var i;176
for(i=0;i<obj.length;i++)177
obj[i].style.visibility="hidden";178
}179

function showAllSelect()
{180
var obj;181
obj=document.getElementsByTagName("SELECT");182
var i;183
for(i=0;i<obj.length;i++)184
obj[i].style.visibility="visible";185
}186

浙公网安备 33010602011771号