如何根据地理位置隐藏html页面?

时间:2019-04-14 09:45:23

标签: javascript php html

请考虑让我拥有一个html页面..

我想向非印度(IN)用户显示该页面,并向其他国家/地区的用户显示该页面...

https://einthusan.tv ..

请任何人帮助我提供完整的工作代码....

1 个答案:

答案 0 :(得分:0)

您可以使用此

$.get("https://ipinfo.io", function(response) {
    console.log(response.city, response.country);
    if(response.country == 'KR'){
        //handle your logic here
        alert('You can not see this content');
        //window.location.href = '/yourlink';
    }
}, "jsonp");

$.get("https://ipinfo.io", function(response) {
    console.log(response.city, response.country);
    if(response.country == 'KR'){
        //handle your logic here
        alert('You can not see this content');
        //window.location.href = '/yourlink';
    }
}, "jsonp");
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>