2016-05-23 4 views
1

IPリダイレクトをIPで選択します。どのようなアイデアでも動作しませんか?ip geolocationによるリダイレクトリンク

のget IP

<script> 
$.get("http://ipinfo.io", function (response) { 
    $("#address").html(response.region); 
}, "jsonp"); 
</script> 


<div style="display:none;" id="address" name="address"></div> 

リダイレクトスクリプト

<script type="text/javascript"> 

function Redirect() { 
var address = document.getElementById("address").value; 
window.location.replace = "https://google.com/"+address+""; 
} 

document.write("You will be redirected to main page in 0 sec."); 
setTimeout('Redirect()', 0); 

</script> 

答えて

2

ゲットIP &リダイレクトリンク

<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script> 

<script type="text/javascript"> 
    $.getJSON('http://ipinfo.io', function (response) { 
     $("#address").html(response.region); 

     var address = (response.region); 
     window.location = "https://google.com/"+address+""; 
    }); 
</script> 
+0

これは自動応答ですか? –

+1

@JuanjoSalvador no ,,,,その自動応答ではない、私は私の質問から解決策を見つける、と私はすべてのために共有したい。多分同じ問題の人々を助ける... –

関連する問題