Invision Community 4: SEO, prepare for v5 and dormant account notifications Matt November 11, 2024Nov 11
Posted October 3, 20204 yr 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 October 3, 20204 yr by marklcfc
October 7, 20204 yr 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
October 7, 20204 yr I have installed AdBlock and it does not block the script You should to change advertisement.js on the name which adblock blocks
October 7, 20204 yr 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 October 7, 20204 yr by marklcfc
October 7, 20204 yr 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=
October 7, 20204 yr 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 October 7, 20204 yr by marklcfc
October 7, 20204 yr Uncaught ReferenceError: ga is not defined Comment the line ga('send', 'event', 'Adblock Check', 'display', 'alert');
October 7, 20204 yr Author Thanks @newbie LAC that is working now 🙂 Edited October 7, 20204 yr by marklcfc