javascript實(shí)現(xiàn)無法關(guān)閉的彈框
更新時(shí)間:2016年11月27日 15:48:55 作者:九成
本文分享了javascript實(shí)現(xiàn)無法關(guān)閉的彈框的實(shí)例代碼,感興趣的朋友可以看下
大家都見過某網(wǎng)頁中的惡意廣告,你關(guān)閉了又出來了!為何,JS來告訴你
HTML
<body>
<h3 class="whiteColor">無法關(guān)閉的彈框,打不死的小強(qiáng)!</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();
};
以上就是本文的全部內(nèi)容,希望對大家有所幫助,同時(shí)也希望多多支持腳本之家!
您可能感興趣的文章:
- js+html5實(shí)現(xiàn)半透明遮罩層彈框效果
- vue.js中toast用法及使用toast彈框的實(shí)例代碼
- js自定義彈框插件的封裝
- 輕松實(shí)現(xiàn)js彈框顯示選項(xiàng)
- vue.js實(shí)現(xiàn)只彈一次彈框
- js重寫alert事件(避免alert彈框標(biāo)題出現(xiàn)網(wǎng)址)
- js實(shí)現(xiàn)上下左右彈框劃出效果
- 基于layer.js實(shí)現(xiàn)收貨地址彈框選擇然后返回相應(yīng)的地址信息
- JavaScript實(shí)現(xiàn)alert彈框效果
- JavaScript封裝彈框插件的方法
相關(guān)文章
Javascript連接Access數(shù)據(jù)庫完整實(shí)例
這篇文章主要介紹了Javascript連接Access數(shù)據(jù)庫的方法,涉及javascript針對access數(shù)據(jù)庫的連接、關(guān)閉及增刪改查等常用操作技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下2015-08-08
JavaScript實(shí)現(xiàn)點(diǎn)擊自動(dòng)選擇TextArea文本的方法
這篇文章主要介紹了JavaScript實(shí)現(xiàn)點(diǎn)擊自動(dòng)選擇TextArea文本的方法,涉及javascript中focus()、select()方法的使用技巧,非常簡單實(shí)用,需要的朋友可以參考下2015-07-07
詳解js正則表達(dá)式驗(yàn)證時(shí)間格式xxxx-xx-xx形式
本篇文章主要介紹了詳解js正則表達(dá)式驗(yàn)證時(shí)間格式xxxx-xx-xx形式,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2018-02-02
JavaScript中遍歷跳出循環(huán)方法總結(jié)
這篇文章主要給大家介紹了關(guān)于JavaScript中遍歷跳出循環(huán)方法的相關(guān)資料,一想到想到循環(huán)的跳出,立馬就會(huì)想到三個(gè)關(guān)鍵,break、return、continue,在業(yè)務(wù)中也會(huì)需要在遍歷的時(shí)候退出循環(huán),需要的朋友可以參考下2023-12-12
在bootstrap中實(shí)現(xiàn)輪播圖實(shí)例代碼
Bootstrap中輪播圖插件叫作Carousel ,下面通過本文給大家詳細(xì)介紹了bootstrop中實(shí)現(xiàn)輪播圖效果,需要的朋友參考下2017-06-06

