I am working on a WordPress site and I have placed the following code in my JavaScript file:
function blockAdblockUser() {
if ($('.sideAd').height() == 0) {
"<a href='http://google.com' target='_blank'><img src='image.png' /></a>";
}
}
$(document).ready(function(){
blockAdblockUser();
});
…and I put the following code in my html…
<section class="sideAd">
<!-- google ad script here -->
</section>
Basically, I am trying to get the alternate image to show up if the user is blocking ads with AdBlock. However, with AdBlock turned on, the image doesn’t show. I am thinking there is something wrong with how I wrote this line "<a href='http://google.com' target='_blank'><img src='image.png' /></a>";
I am still a novice when it comes to JavaScript.
Can anybody see where the problem is?
You need to take the string that you’ve made and actually set it as the inner html. You can fix it by changing the inner line to:
try: