Vally Posted December 18, 2013 Report Share Posted December 18, 2013 Asta e codul original.<script language="JavaScript" src="http://j.maxmind.com/app/geoip.js"></script><script language="JavaScript">var country = geoip_country_code();switch (country){case (country = "US"): //Tier1window.location = "http://google.ro/tier1";break;case (country = "GB"): //Tier1window.location = "http://google.ro/tier1";break;case (country = "AU"): //Tier2window.location = "http://google.ro/tier2";break;case (country = "RO"): //Tier2window.location = "http://google.ro/tier2";break;case (country = "DK"): //Tier2window.location = "http://google.ro/tier2";break;default:window.location = "http://google.ro/restofworld";break;}</script>As vrea sa arate asa. Sa pot pune mai multe tari pentru o singura locatie. Eu am pus virgula (,) intre codurile tarilor, dar nu funtioneaza.<script language="JavaScript" src="http://j.maxmind.com/app/geoip.js"></script><script language="JavaScript">var country = geoip_country_code();switch (country){case (country = "US,GB"): //Tier1window.location = "http://google.ro/tier1";break;case (country = "AU,RO,DK"): //Tier2window.location = "http://google.ro/tier2";break;default:window.location = "http://google.ro/restofworld";break;}</script>Fac donatie paypal, tansfer bancar, cash in craiova. Quote Link to comment Share on other sites More sharing options...
Pacalici Posted December 18, 2013 Report Share Posted December 18, 2013 Ai incercat asa:<script language="JavaScript" src="http://j.maxmind.com/app/geoip.js"></script><script language="JavaScript">var country = geoip_country_code();switch (country){case "US":case "GB": //Tier1window.location = "http://google.ro/tier1";break;case "AU":case "RO":case "DK": //Tier2window.location = "http://google.ro/tier2";break;default:window.location = "http://google.ro/restofworld";break;}</script> Quote Link to comment Share on other sites More sharing options...
Vally Posted December 18, 2013 Author Report Share Posted December 18, 2013 varianta ta e mult mai eficienta, dar se poate sa le pui cu virgula (,) intre tari? Quote Link to comment Share on other sites More sharing options...
GarryOne Posted December 18, 2013 Report Share Posted December 18, 2013 (edited) Ai putea incerca ceva de genul.<script>function isInArray(value, array) { return array.indexOf(value) > -1 ? true : false;}var country = geoip_country_code();if (isInArray(country, ["US", "GB"])) { window.location = "http://google.ro/tier1";} else if (isInArray(country, ["AU", "RO", "DK"])) { window.location = "http://google.ro/tier2";} else { window.location = "http://google.ro/restofworld";}</script>Testat. Edited December 18, 2013 by GarryOne Quote Link to comment Share on other sites More sharing options...
nedo Posted December 18, 2013 Report Share Posted December 18, 2013 In mod normal pentru switch, nu prea ai cum sa pui cu virgula, si nici nu vad de ce ai face-o. Poti incerca asa cum ti-a sugerat GarryOne dar nu mai folosesti switch ci if-uri. Quote Link to comment Share on other sites More sharing options...
Pacalici Posted December 18, 2013 Report Share Posted December 18, 2013 Pana la urma case-u e un fel de switch. Si da, cum a zis Garry ar fi mult mai sigur. Quote Link to comment Share on other sites More sharing options...