Jump to content

Adblock help

Featured Replies

Posted

I have some code I used for a few years which displayed a message to users using adblock. It doesn't work anymore. Can anyone help fix it? It wasn't used an as official hook, just placed into globaltemplate and a simple .js file.

Edited by marklcfc

  • Author

These are the details if anyone can help. See the attached a .js file. Then I put this in my globalte

<script type="text/javascript" src="/advertisement.js"></script>
<script type="text/javascript">
      if (document.getElementById("tester") != undefined)
                {
                    document.write(' ');
                }
      else
                {
                    ga('send', 'event', 'Adblock Check', 'display', 'alert');
                    document.write('<div class="ipsMessage ipsMessage_error adblockDetectedMessage" style="margin-bottom: 0;"><a href="https://www.wikihow.com/Disable-AdBlock" target="_blank" id="helpTopicLink" class="ipsMessage_code ipsType_blendlinks ipsPos_right" title="How to disable adblock?" data-ipsTooltip><i class="fa fa-question"></i></a></div>');
                }
</script>

Then I added this in styles.css to hide the checker part.

#tester {
	display:none;
}

But no message is appearing anymore

advertisement.js

I have installed AdBlock and it does not block the script

You should to change advertisement.js on the name which adblock blocks

  • Author
14 minutes ago, newbie LAC said:

I have installed AdBlock and it does not block the script

You should to change advertisement.js on the name which adblock blocks

Did it not work? I couldn't understand if was saying it did or not.

I've reinstalled it on my site, do you see the message @newbie LAC  as I don't. https://www.foxestalk.co.uk/

Edited by marklcfc

14 minutes ago, marklcfc said:

do you see the message

No

14 minutes ago, marklcfc said:

You should to change advertisement.js on the name which adblock blocks

change advertisement.js to advertisement.js?&ad_code=

  • Author
19 minutes ago, newbie LAC said:

No

change advertisement.js to advertisement.js?&ad_code=

I changed that line in globaltemplate to 

<script type="text/javascript" src="/advertisement.js?&ad_code="></script>

It's not showing, not sure if I was meant to put something else after =

It shows occasionally when I hard refresh the page though

Edited by marklcfc

Uncaught ReferenceError: ga is not defined

Comment the line 

                    ga('send', 'event', 'Adblock Check', 'display', 'alert');

 

  • Author

Thanks @newbie LAC that is working now 🙂

Edited by marklcfc

Recently Browsing 0

  • No registered users viewing this page.