Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <title>AdBlocker Detection</title>
- <script>
- document.addEventListener('DOMContentLoaded', function() {
- var adBlockEnabled = false;
- // Create a dummy ad element
- var testAd = document.createElement('div');
- testAd.innerHTML = ' ';
- testAd.className = 'adBanner';
- // Append the dummy ad element to the document
- document.body.appendChild(testAd);
- // Check if the dummy ad element is blocked or hidden
- if (testAd.offsetHeight === 0 || testAd.style.display === 'none') {
- adBlockEnabled = true;
- }
- // Remove the dummy ad element
- document.body.removeChild(testAd);
- // Display a message based on the result
- if (adBlockEnabled) {
- document.getElementById('adBlockMessage').style.display = 'block';
- } else {
- document.getElementById('adBlockMessage').style.display = 'none';
- }
- });
- </script>
- <style>
- #adBlockMessage {
- display: none;
- background-color: #f2dede;
- color: #a94442;
- padding: 10px;
- margin: 10px;
- }
- </style>
- </head>
- <body>
- <h1>AdBlocker Detection Example</h1>
- <div id="adBlockMessage">
- <p>It appears that you have an AdBlocker enabled. Please disable it to view the content.</p>
- </div>
- <!-- Rest of your content goes here -->
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement