提示用户关闭广告屏蔽插件的JS代码

广告是很多站长最有效的收入来源,但现在各种广告屏蔽插件导致无法正常运作,那么我们给安装这类插件的网友一个提醒,让其关闭一下!


添加伪广告元素

这一步是为了,让广告屏蔽插件,屏蔽掉我们自己创建的元素,好后期判断是否存在这个var变量。在网站根目录新建一个adview_pic_cpc_cpm_cpa_guanggao_gg_ads_300x250.js文件,里面的内容如下

var adskilltest=true;

 

footer.php

在你的底部文件footer.php中</body>前,插入如下代码。

<script src=”/adview_pic_cpc_cpm_cpa_guanggao_gg_ads_300x250.js” type=”text/javascript”></script>
<style type=”text/css”>
.addkillcont{position: fixed;z-index: 999999;bottom: 0px;background: #CCC;width:100%; filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#BF000000,endColorstr=#00000000);} .addesc{position: relative;margin-left: auto;margin-right: auto;background: #FFF;border: 1px solid #CCC;webkit-box-shadow: 0 0 20px rgba(27,22,22,0.3);-moz-box-shadow: 0 0 20px rgba(27,22,22,0.3);-o-box-shadow: 0 0 20px rgba(27,22,22,0.3);box-shadow: 0 0 20px rgba(27,22,22,0.3);padding: 10px;margin-top: 10px;font-family: “Microsoft Yahei”,”Helvetica Neue”,Helvetica,Arial,sans-serif;} </style>
<script type=’text/javascript’>
$(document).ready(function(){ setTimeout(function(){new QXAdTest().init();},1); }); function QXAdTest(
){ var thisObj = this; //初始化,判断变量是否存在 this.init = function(){ try{ if(typeof(adskilltest)==’undefined’ ){ this.DoShow(); $(‘.idcloseadtips’).on(“click”,function(){ $(“#idadkillsho”).remove(); }); } }catch(e){ $(“#idadkillsho”).remove(); } }; this.DoShow =function(){ try{ var TPL='<div id=”idadkillsho” class=”addkillcont”>’ + ‘<div class=”addesc” id=”addesc” style=”display:none;”>’ + ‘<div style=”color:red;font-weight:bold; text-align:center;”>屏蔽广告虽易,做网站不易,且屏蔽且珍惜…</div>’+ ‘<span class=”idcloseadtips” style=”position:absolute;right:10px;bottom:10px;font-weight:bold;color:gray;cursor:pointer”><i class=”fa fa-times-circle”></i></span>’+ ‘</div>’ + ‘</div>’; var TPLObj = $(TPL); TPLObj.appendTo($(‘header’)).hide().fadeIn(500,function(){ $(“#addesc”).animate({“margin-top”:”0″},600); $(“#addesc”).slideDown(500,function(){ $(“#addesc”).animate({“height”:”40px”},600); } ); }); }catch(e){ $(“#idadkillsho”).remove();//一定移除 } } } </script>