0

I have 2 sets of banner code for displaying banners:

1) Ad server code which gets blocked by AdBlock 2) Plain HTML banner insertion which AdBlock does not block

My questions is:

How can I use Javascript (or something else, for that matter) to insert the plain Javascript banner code if AdBlock is detected.

For reference, I found this AdBlock detection code:

document.write('<div id="tester" style="display:none">an advertisemen</div>');

<script type="text/javascript" src="advert.js"></script>
<script type="text/javascript">
if (document.getElementById("tester") == undefined) 
{ 
document.write(' TEXT TO DISPLAY IF ADBLOCK IS ACTIVE'); 
}

1 Answer 1

0

Using code provide by you:

document.write('<div id="tester" style="display:none">an advertisemen</div>');

<script type="text/javascript" src="advert.js"></script>
<script type="text/javascript">
if (document.getElementById("tester") == undefined) 
{ 
document.write('HTML banner code here'); 
} else {
docuement.write('Ad Server code here')
}

Both of your HTML banner and Ad Server codes will be in JavaScript which write a div to the core HTML file at a specific DOM point. Example: Add HTML elements dynamically with JavaScript inside DIV with specific ID

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.