I've recently completed the coding and CSS for my website after working on it for quite some time. Now, I want to enhance it by incorporating new features. The website is fully operational and generates revenue primarily through Google AdSense. I am interested in displaying different images based on whether Adblock is active or not.
Here is the method I found for detecting AdSense activity:
JS (saved as advertisement.js
)
document.write('<div id="TestAdBlock" style="display:none;">an advertisement</div>');
The part of HTML code:
<div id="adblockFrame">
<script type="text/javascript" src="js/advertisement.js"></script>
<script type="text/javascript">
if (document.getElementById("TestAdBlock") != undefined)
{
document.write('<img src="image1.jpg" alt="Image A">');
}
else
{
document.write('<img src="image2.jpg" alt="Image B">');
}
</script>
</div>
CSS:
#adblockFrame {
visibility: hidden;
}
I am seeking assistance from someone who can help me modify the JS code to display images instead of text. My understanding of JS is limited, so any support would be greatly appreciated.