{Google AdSense users} Adding a FF button if your anti-virus prevents your Google ad to be shown...

Posted by maraja on Fri, 10/12/2007 - 16:49For the Record

Hallo there,

after quite a good amount of stress and investigation I found out that my anti-virus software (Kaspersky) was blocking my Google Ads.

As I like to help spreading the Fox I have then prepared some JavaScript code to show a SpreadFireFox button on the page of users having their anti-virus blocking the ads.

This is the code Google gives you to add the banner (personal code replaced by ***):

<blockquote>
        <p id="googleAd" style="margin:-14px 20px 0 30px;">&bull;
            <script type="text/javascript"><!--
            google_ad_client = "pub-**************";
            google_ad_output = "textlink";
            google_ad_format = "ref_text";
            google_cpa_choice = "CAAQjbiylAIaCFDA2CpLIq2IKNW34YcBMAA";
            google_ad_channel = "***********";
            //-->
            </script>
            <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
        </p>
</blockquote>

Following is the code to add right after the closing paragraph tag:
<blockquote>
        <script type="text/javascript">
            /*
                if the googleAd is filtered by an anti-virus, show the alternative message
            */
            var el = document.getElementById('googleAd');
            var i = el.innerHTML.toLowerCase().indexOf('firefox');
            if(i < 0)
            {
                // googleAd was blocked
                var link = document.createElement('a');
                link.href = '?q=affiliates&amp;id={YOUR AFFILIATE ID GOES HERE}&amp;t=219';
                var img = document.createElement('img');
                img.src = 'http://sfx-images.mozilla.org/affiliates/Buttons/firefox2/ff2b80x15.gif';
                img.style.border = '0';
                img.title = 'Firefox 2';
                img.align='absmiddle';
                link.appendChild(img);
                el.appendChild(link);
                var text = document.createTextNode(' my preferred browser since version 1.0!');
                el.appendChild(text);
            }
        </script>
</blockquote>


That's it: just wanted to share this with you!