JavaScript實(shí)現(xiàn)廣告彈窗效果
更新時(shí)間:2016年08月09日 11:36:15 作者:九成
這篇文章主要為大家詳細(xì)介紹了JavaScript實(shí)現(xiàn)廣告彈窗效果,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
大家都見過(guò)某度中的惡意廣告,你關(guān)閉了又出來(lái)了!為何,JS來(lái)告訴你
HTML
<body>
<h3 class="whiteColor">無(wú)法關(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();
};
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
您可能感興趣的文章:
- JS實(shí)現(xiàn)關(guān)閉小廣告特效
- js實(shí)現(xiàn)左右兩側(cè)浮動(dòng)廣告
- javascript實(shí)現(xiàn)循環(huán)廣告條效果
- 基于JavaScript實(shí)現(xiàn)淘寶商品廣告效果
- 用js屏蔽被http劫持的浮動(dòng)廣告實(shí)現(xiàn)方法
- JS使用cookie實(shí)現(xiàn)只出現(xiàn)一次的廣告代碼效果
- JavaScript實(shí)現(xiàn)彈出廣告功能
- 原生js實(shí)現(xiàn)網(wǎng)頁(yè)頂部自動(dòng)下拉/收縮廣告效果
- JavaScript cookie 跨域訪問(wèn)之廣告推廣
- JS前端廣告攔截實(shí)現(xiàn)原理解析
相關(guān)文章
Layui實(shí)現(xiàn)主窗口和Iframe層參數(shù)傳遞
今天小編就為大家分享一篇Layui實(shí)現(xiàn)主窗口和Iframe層參數(shù)傳遞,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2019-11-11
javascript實(shí)現(xiàn)拍照功能詳細(xì)示例代碼
這篇文章主要給大家介紹了關(guān)于javascript實(shí)現(xiàn)拍照功能的相關(guān)資料, 最近做項(xiàng)目,遇到一個(gè)正常但又少見的需求之拍照,文中給出了詳細(xì)的代碼示例,需要的朋友可以參考下2023-07-07
Mock.js的安裝與使用教程(擺脫后端同學(xué)的束縛)
Mock功能可以根據(jù)接口/數(shù)據(jù)結(jié)構(gòu)定義、Mock規(guī)則配置、Mock?期望配置,自動(dòng)生成模擬數(shù)據(jù),且使用者可以根據(jù)需要靈活構(gòu)造各種結(jié)構(gòu)的接口數(shù)據(jù),下面這篇文章主要給大家介紹了關(guān)于Mock.js的安裝與使用的相關(guān)資料,需要的朋友可以參考下2022-08-08
js判斷手機(jī)系統(tǒng)是android還是ios
本文主要介紹了js判斷手機(jī)系統(tǒng)是android還是ios的方法,具有很好的參考價(jià)值。下面跟著小編一起來(lái)看下吧2017-03-03
JS實(shí)現(xiàn)倒計(jì)時(shí)圖文效果
這篇文章主要為大家詳細(xì)介紹了JS實(shí)現(xiàn)倒計(jì)時(shí)圖文效果,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2018-11-11

