Javascript 如何显示/隐藏特定国家/地区的内容

Javascript 如何显示/隐藏特定国家/地区的内容,javascript,jquery,html,geolocation,blogger,Javascript,Jquery,Html,Geolocation,Blogger,只有在巴基斯坦才有内容展示。我有一个巴基斯坦公司的广告横幅,我只想在巴基斯坦展示该横幅。您可以使用名为fromsmart ip.net的服务。: $(function() { $.getJSON('http://smart-ip.net/geoip-json?callback=?', function(data) { if (data.countryCode == 'PK') { $('#ad_banner').show();

只有在巴基斯坦才有内容展示。我有一个巴基斯坦公司的广告横幅,我只想在巴基斯坦展示该横幅。

您可以使用名为from
smart ip.net的服务。

$(function() {
    $.getJSON('http://smart-ip.net/geoip-json?callback=?', function(data) {
        if (data.countryCode == 'PK') {
            $('#ad_banner').show();
            $('body').text('You are from Pakistan');
        }else{
            $('#ad_banner').hide();
            $('body').text('You are from ' + data.countryName);
        }
    });
});
其中,
PK