web建站教程
  1. 首页
  2. vuejs
  3. js
  4. 好玩
  5. seo教程
  6. 前端知识
  7. 百度echarts
  8. 更多
    php入门
    nodejs
    mockjs
    reactjs
    mysql
    wordpress
    织梦cms
    帝国cms
    git教程
    IT知识
    模板大全
    休息站

js判断AdBlock广告是否开启拦截

456 ℃
     

js判断当前网站是否开启了AdBlock广告拦截功能,如果开启AdBlock插件显示提示“为了支持本项目的长期发展,请将本网站加入广告拦截器的白名单。”,否则不显示!

function ABDetected(){
  var adBlockDetected_div=document.createElement("div");
  adBlockDetected_div.style.cssText="position: absolute; top: 0; left: 0; width: 100%; background: #fc6600; color: #fff; z-index: 9999999999; font-size: 14px; text-align: center; line-height: 1.5; font-weight: bold; padding-top: 6px; padding-bottom: 6px;";adBlockDetected_div.innerHTML="为了支持本项目的长期发展,请将本网站加入广告拦截器的白名单。";
  document.getElementsByTagName("body")[0].appendChild(adBlockDetected_div);
  var adBlockDetected_close=document.createElement("div");
  adBlockDetected_close.style.cssText="position: absolute; top: 0; right: 10px; width: 30px; height: 30px; background: #fc6600; color: #fff; z-index: 9999999999; line-height: 30px; cursor: pointer;";
  adBlockDetected_close.innerHTML="×";
  adBlockDetected_div.appendChild(adBlockDetected_close);
  adBlockDetected_close.onclick=function(){
    this.parentNode.parentNode.removeChild(this.parentNode)
  }
}
function docReady(t){
  "complete"===document.readyState||"interactive"===document.readyState?setTimeout(t,1):document.addEventListener("DOMContentLoaded",t)
}
docReady(function(){
  setTimeout(function(){
    if(window._AdBlockInit===undefined){
	  ABDetected()
	}
  },3e3)
});

js用最简单的方法实现2个数组的交叉一对一合并

如何利用js语法将2个数组进行交叉合并

利用js语法把数组根据相同key转换成嵌套数组格式

javascript语法如何把json文件输出到html页面上

js点击按钮从服务器上下载json文件(不是打开文件)

标签: AdBlock广告, AdBlock插件, js广告判断

上面是“js判断AdBlock广告是否开启拦截”的全面内容,想了解更多关于 js 内容,请继续关注web建站教程。

当前网址:https://ipkd.cn/webs_13653.html

声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!

当前位置: 网站首页 > js
本文共计1199个字,预计阅读时长8分钟
生活小工具,收录了80多款小工具
上一篇: 推荐一款免费开源的屏幕录制软件——OBS Studio
下一篇: 推荐一个高质量的图片素材网站——Unsplash
x 打工人ai神器