js 弹出框 替代浏览器的弹出框

时间:2021-05-26

复制代码 代码如下:
function fromID(id) {
return document.getElementById(id);
}

function show_alert(msg, type, time) {
var layer_obj = fromID("alert_layer");
var layer_text= fromID("alert_text");
var line_height = (document.documentElement.scrollTop == 0) ? document.body.scrollTop : document.documentElement.scrollTop;

layer_text.innerHTML = msg;
with(layer_obj.style) {
zIndex = 999;
top = line_height-40;
left = document.body.clientWidth/3;
display = "block";
position = "absolute";
if(type == "error") {
background = "url(http://"+style_domain+"/snake/index/msgbox_right_bg2.jpg)";
}
}

layer_obj.filters[0].opacity = "0.8"; //透明度为 80%

if(time == undefined) time = 3000;
else time = time*1000;

var top = line_height-40;
var speed = 1.5;
time-= 1000;
//控制窗口向下移动至页面边缘
move_down = function MoveFplogo() {
top+= speed;
layer_obj.style.top = top;
if(top < line_height) setTimeout("move_down()", 1);
else setTimeout("close_alert_win()", time);
}

move_down();
}

function close_alert_win() {
var layer_obj = fromID("alert_layer");
//控制窗口渐渐消失
if(layer_obj.filters[0].opacity < 0.02) {
layer_obj.style.display = "none";
return true;
}
layer_obj.filters[0].opacity-= 0.02;
setTimeout("close_alert_win()", 1);
}
document.writeln(" filter:progid:DXImageTransform.Microsoft.BasicImage();">");
document.writeln(" ");
document.writeln(" ");
document.writeln("");

声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。

相关文章