Iklan

How to Add Detect Adblock Messages with JavaScript in Blogger Blog

How Adding Messages to Detect Adblock with JavaScript in Blogger Blog

I will share with you another tutorial. And this tutorial is " How Adding Messages to Detect Adblock with JavaScript in Blogger Blog " If my friend wants to know whether visitors on your blog blocking Google AdSense ads or not, my friend can do so by adding JavaScript code.

The workings of the JavaScript code that will I share this is the Adblock extension automatically detects if the visitor has Adblock browser they use when opening your blog to bring a special message. JavaScript code is already supporting
The new format of the data Asynchronous Responsive Google Adsense ads and utilize selector ins.adsbygoogle then replace it with a message when Adblock active in your browser.



How to Add Message to Detect Adblock with JavaScript

This code is also quite light, so my friend does not need to worry if the code is going to weigh on the loading speed of your blog. For those who want to try please follow these steps:


1. Log in to Blogger >> Open Template Editor >> Then add the following code before the </body>


Java Script - Go Widget

<script type='text/javascript'>
//<![CDATA[
// Adblock Detected
window.onload=function(){setTimeout(function(){var e=document.querySelector("ins.adsbygoogle");e&&0==e.innerHTML.replace(/\s/g,"").length&&(e.style.cssText="color:rgba(0,0,0,0.5);font-weight:700;font-size:110%;padding:20px;margin:auto;text-align:center;text-decoration:none;display:block!important;background:rgba(0,0,0,0.02);border:1px solid rgba(0,0,0,0.08)",e.innerHTML="It seems you block Google AdSense ads on your browser")},2e3)};
//]]>
</script>


* Example display the message: *

How Adding Messages to Detect Adblock with JavaScript in Blogger Blog

Description


Java Script - Go Widget

e.style.cssText="color:rgba(0,0,0,0.5);font-weight:700;font-size:110%;padding:20px;margin:auto;text-align:center;text-decoration:none;display:block!important;background:rgba(0,0,0,0.02);border:1px solid rgba(0,0,0,0.08)"


Code marked a CSS display a message, please modify according to your wishes


Java Script - Go Widget

e.innerHTML="It seems you block Google AdSense ads on your browser"



Replace the code that is marked with your writing.

2. If it has been added, save the template and then check the blog and activate Adblock to ensure the code is running properly. Thus tutorial about “ How Adding Messages to Detect Adblock with JavaScript in Blogger Blog

Hopefully 

Next
Prev Post
Previous
Next Post
Buka Komentar