javascript实现无法关闭的弹框
作者:九成 时间:2024-05-08 09:32:13
大家都见过某网页中的恶意广告,你关闭了又出来了!为何,JS来告诉你
HTML
<body>
<h3 class="whiteColor">无法关闭的弹框,打不死的小强!</h3>
<div id="middleBox">
<a href="javascript:;" class="close_btn" id="closeBtn"><img src="images/close_icon.png" alt="" class="will_close"></a>
<ul class="parent_btn">
<li><a href="/" class="btn_tel"><img src="images/icon_tel.gif" alt=""><span>拨打电话</span></a></li>
<li><a href="/" class="btn_chat"><img src="images/icon_chat.gif" alt=""><span>快速留言</span></a></li>
</ul>
</div>
</body>
CSS
*{
margin: 0;
padding: 0;
list-style: none;
outline: none;
box-sizing: border-box;
text-decoration: none;
}
a { -webkit-touch-callout: none; text-decoration: none }
:focus { outline: 0 }
body{
font-family: Helvetica, STHeiTi, "Microsoft YaHei", sans-serif;
color: #595757;
background-color: #fff;
outline: 0;
overflow-x: hidden;
-webkit-tap-highlight-color:rgba(0,0,0,0);
}
img{
border: none;
}
.whiteColor{
color: #fff;
text-align: center;
}
.flex_parent{
display: -webkit-box;
display: -moz-box;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
}
.flex_child{
-webkit-box-flex: 1;
-moz-box-flex: 1;
-webkit-flex: 1;
-ms-flex: 1;
flex: 1;
}
/*middle_box*/
body{
position: relative;
background-color: #272822;
}
#middleBox{
width: 260px;
height: 248px;
margin: 0 auto;
background-image: url(../images/irfa_dog.jpg);
background-repeat: no-repeat;
background-size: 100% 100%;
border-radius: 10px;
/*水平垂直居中*/
position: fixed;
left: 50%;
top: 50%;
margin-top: -124px;
-webkit-transform: translateX(-50%);
-moz-transform: translateX(-50%);
-o-transform: translateX(-50%);
-ms-transform: translateX(-50%);
transform: translateX(-50%);
z-index: 100;
}
.close_btn{
display: block;
overflow: hidden;
position: absolute;
top: -10px;
right: -10px;
}
.will_close{
width:32px;
}
#middleBox a{
overflow: hidden;
}
#middleBox a img,#middleBox a span,#middleBox ul li{
float: left;
}
#middleBox a span{
font-size: 16px;
color: #fff;
}
#middleBox ul{
overflow: hidden;
}
#middleBox ul li{
width: 130px;
}
#middleBox ul li a{
line-height: 50px;
display: block;
padding-left: 5px;
}
#middleBox ul li a img{
width:30px;
margin-right: 2px;
margin-top: 8px;
margin-left: 5px;
}
.btn_tel{
background-color: #F92665;
border-bottom-left-radius: 10px;
}
.btn_chat{
background-color: #1EA362;
border-bottom-right-radius: 10px;
}
.parent_btn{
position: absolute;
left: 0;
bottom: 0;
}
JS
/**
* Created by Administrator on 2016/7/19.
*/
var adv={
div:null,
timer:null,
btn:null,
init:function(){
this.btn=document.getElementById("closeBtn");
this.div=document.getElementById("middleBox");
this.btn.onclick=this.displayNone;
},
displayBlock:function(){
adv.div.style.display="block";
},
displayNone:function(){
adv.div.style.display="none";
timer=setTimeout(function(){
adv.displayBlock();
},3000);
}
};
window.onload=function(){
adv.init();
};
来源:http://www.cnblogs.com/-walker/p/5685490.html
标签:js,弹框
0
投稿
猜你喜欢
显示/隐藏引出的CSS Bug
2010-10-20 20:13:00
ASP解析JSON
2009-12-25 16:34:00
keras之权重初始化方式
2023-06-01 19:04:44
django 模版关闭转义方式
2023-07-18 15:23:03
解决MySQL数据库链接超时报1129错误问题
2024-01-17 12:15:04
Python爬虫实战之网易云音乐加密解析附源码
2022-08-28 04:03:58
async/await与promise(nodejs中的异步操作问题)
2024-04-22 22:43:39
关于SSD目标检测模型的人脸口罩识别
2023-06-20 05:20:56
Anaconda之conda常用命令介绍(安装、更新、删除)
2021-06-11 22:52:03
MySQL 视图 第1349号错误解决方法
2024-01-18 14:45:41
Linux自动备份MySQL数据库脚本代码
2024-01-24 05:00:12
echarts学习之legend点击事件解读
2024-05-03 11:10:17
利用python为运维人员写一个监控脚本
2021-01-19 16:12:37
js实现简单放大镜特效
2024-04-30 08:51:48
Python方法的延迟加载的示例代码
2022-09-05 03:25:00
如何使用FSO搜索硬盘文件
2007-09-27 12:59:00
详谈python http长连接客户端
2023-07-30 22:37:01
反向传播BP学习算法Gradient Descent的推导过程
2022-09-08 09:51:06
python 负数取模运算实例
2022-06-17 00:50:49
Python中判断input()输入的数据的类型
2023-03-14 17:02:15