Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

JS to rotate Adsense per browser type

  • 19-07-2006 2:52pm
    #1
    Registered Users, Registered Users 2 Posts: 3,514 ✭✭✭


    Hi guys. i have signed up google adsense and i'm using their referral adverts for firefox and picasso but i only want to display one referral at a time on a page. I don't see much point in advertising the firefox referral to users who are already viewing the page using firefox so is it possible to write some JS which will only display the firefox referal to users of non firefox browsers and that will also display both the firefox and picasso referrals to all other users (IE/Safare/Netscape/Opera)

    I attempted this myself but i'm not that great on JS. Here is my attempt using an if statement
    [html]
    <SCRIPT language="JavaScript"><!--
    if(navigator.userAgent.indexOf("Firefox")!=-1){
    var versionindex=navigator.userAgent.indexOf("Firefox")+8
    if (parseInt(navigator.userAgent.charAt(versionindex))>=1)

    google_ad_client = "pub-7213854248425086";
    google_ad_width = 125;
    google_ad_height = 125;
    google_ad_format = "125x125_as_rimg";
    google_cpa_choice = "CAAQ6OGIlAIaCFN_N8Za4RF6KITHrYMB";
    google_ad_channel = "";
    src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
    }
    else {
    google_ad_client = "pub-7213854248425086";
    google_ad_width = 125;
    google_ad_height = 125;
    google_ad_format = "125x125_as_rimg";
    google_cpa_choice = "CAAQveHnzwEaCEiH5iXPqf1SKJe193M";
    google_ad_channel = "";
    src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
    </script>
    [/html]

    Is Google ok with this slight modification of their setup?


Comments

  • Registered Users, Registered Users 2 Posts: 3,514 ✭✭✭Rollo Tamasi


    Working code:
    [html]
    <SCRIPT language="JavaScript">
    <!--
    google_ad_client = "pub-7213854248425086";
    google_ad_width = 125;
    google_ad_height = 125;
    google_ad_format = "125x125_as_rimg";
    google_ad_channel = "";
    var ieArray=["CAAQveHnzwEaCEiH5iXPqf1SKJe193M","CAAQ6OGIlAIaCFN_N8Za4RF6KITHrYMB"] // Short syntax for an array holding two

    if (navigator.userAgent.indexOf("Firefox")!=-1) {
    google_cpa_choice = "CAAQ6OGIlAIaCFN_N8Za4RF6KITHrYMB";
    } else {
    google_cpa_choice = ieArray[Math.round(Math.random())];
    }

    </SCRIPT>
    <SCRIPT language="JavaScript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></SCRIPT>[/html]


Advertisement