Redirect users of a specific IP address

时间:2016-09-01 06:30:29

标签: javascript redirect ip-address

I am making an IP approval system for my website, and I would like to, if the user has an IP address on the banned list, be redirected to banned.html on my site. I would like some JavaScript code for the head section on my website.

I know that a javascript redirect is...

window.location="banned.html";

But I am not sure of a function that returns the IP.

What code would I put in my head section to do this?

EDIT: This is not a duplicate, as it is asking how to incorporate a redirect into the IP detection.

EDIT: You can use JSON for the IP:

$(document).ready(function () {
    $.getJSON("http://jsonip.com/?callback=?", function (data) {
        console.log(data);
        alert(data.ip);
    });
});

but how do I incorporate a redirect into this, based on if an IP is found on a list.

0 个答案:

没有答案