Created
May 23, 2022 13:58
-
-
Save AnjanaMadu/16e426fc01ec9b18da5b3530d3539777 to your computer and use it in GitHub Desktop.
A script or code can detect whether the client uses or enable the ad blocker.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script> | |
<script> | |
$.ajax({ | |
url: 'https://static.doubleclick.net/instream/ad_status.js', | |
success: function( data ) { | |
console.log("Ads loaded"); | |
}, | |
error: function( data ) { | |
console.log("You're using an ad blocker."); | |
document.body.innerHTML = '<center><br><h1>Turn off your Ads Blocker and refresh the page!</h1></center>'; | |
} | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Did you tested this? 🤔