首页 > web前端 > js教程 > js 弹出框 替代浏览器的弹出框_javascript技巧

js 弹出框 替代浏览器的弹出框_javascript技巧

WBOY
发布: 2016-05-16 18:17:27
原创
1065 人浏览过
复制代码 代码如下:

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 else setTimeout("close_alert_win()", time);
}

move_down();
}

function close_alert_win() {
var layer_obj = fromID("alert_layer");
//控制窗口渐渐消失
if(layer_obj.filters[0].opacity 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("");
相关标签:
来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板