Abed Putra
Abed Putra

Reputation: 1215

Redirect link by ip geolocation

I want link redirect by IP select. but not work, any idea?

get IP

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


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

redirect script

<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>

Upvotes: 1

Views: 1753

Answers (1)

Abed Putra
Abed Putra

Reputation: 1215

Get IP & Redirect link

    <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>

Upvotes: 4

Related Questions