Skip to content

Instantly share code, notes, and snippets.

@necenzurat
Created August 31, 2012 12:14
Show Gist options
  • Save necenzurat/3552021 to your computer and use it in GitHub Desktop.
Save necenzurat/3552021 to your computer and use it in GitHub Desktop.
Banner target on regions
<script language="javascript" src="http://j.maxmind.com/app/geoip.js"></script>
<script language="javascript">
// aici intra linku catre sait
link = "http://redtube.com";
// aici intra imaginea
banner = "http://www.e-oferta.ro/openx/www/images/78004bd0f8cbf0e797e9ee811b8305d9.gif";
// in ce judete sa fie afisat
locatii_de_afisat = ["Cluj","Bucuresti","Timis"];
regiune = geoip_region_name();
function findinarray(arr, obj) {
for(var i=0; i<arr.length; i++) {
if (arr[i] == obj) return true;
}
}
if (findinarray(locatii_de_afisat, regiune)){
document.write("<a href="+ link +" rel='nofollow'><img src="+ banner +"></a>");
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment