リダイレクト用のjsファイルに以下のコードを使用しています..しかし、トップの場所に基づいてリダイレクトしたい. たとえば、誰かが xyz.com にアクセスして mydomain.com にリダイレクトした場合、どのコードを追加する必要がありますか? indexOf('xyz.com') のようになると思います
loadScript("http://j.maxmind.com/app/geoip.js", function() {
var country = geoip_country_code();
if (country === "US") {
window.location = "http://mydomain.com/";
}
});
function loadScript(url, callback) {
// adding the script tag to the head as suggested before
var head = document.getElementsByTagName('head')[0];
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = url;
// then bind the event to the callback function
// there are several events for cross browser compatibility
script.onreadystatechange = callback;
script.onload = callback;
// fire the loading
head.appendChild(script);
}