【问题标题】:How to get ip to information with maxmind javascript如何使用 maxmind javascript 获取 ip 信息
【发布时间】:2014-11-16 01:24:35
【问题描述】:

我想用 maxmind javascript 获取用户的 ip、位置、城市、国家等,但我得到了 null 我有什么错误吗?

我还有一个问题,我可以将 maxmind javascript 放到我的插件中以无限使用吗?

我的 javascript 在这里:

<script src="http://j.maxmind.com/app/geoip.js"></script>
<script>
    $("#country").html(document.write(geoip_country_code()));
    $("#countryname").html(document.write(geoip_country_name()));
    $("#city").html(document.write(geoip_city()));
    $("#region").html(document.write(geoip_region()));
    $("#regionname").html(document.write(geoip_region_name()));
</script>

HTML 在这里

<div id="country">&nbsp;</div>
<div id="countryname">&nbsp;</div>
<div id="city">&nbsp;</div>
<div id="region">&nbsp;</div>
<div id="regionname">&nbsp;</div> 

【问题讨论】:

    标签: javascript php maxmind


    【解决方案1】:

    为什么在 jQuery 命令中使用document.write?以下正确输出我的位置。根据使用限制,您必须阅读their terms of service

    $("#country").html( 'Country: ' + geoip_country_code() );
    $("#countryname").html( 'Country name: ' + geoip_country_name() );
    $("#city").html( 'City: ' + geoip_city() );
    $("#region").html( 'Region: ' + geoip_region() );
    $("#regionname").html( 'Region name: ' + geoip_region_name() );
    div:nth-of-type(odd) {
        background: #e0e0e0;
    }
    div:nth-of-type(even) {
        background: #a5a5a5;
    }
    div {
        padding: 5px;
        margin: 5px;
    }
    <script src="http://j.maxmind.com/app/geoip.js"></script>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
    <div id="country"></div>
    <div id="countryname"></div>
    <div id="city"></div>
    <div id="region"></div>
    <div id="regionname"></div>

    【讨论】:

    • 工作thanx :) 但是如果我在我的网站上使用 maxmind 的 js,每天有 50000 次展示......它是免费的??对于用户?
    • 我不知道,他们的页面说你必须付费。
    • 哦,我真的看到了,每天 50k!,我怀疑你会免费搭车 ;)
    • 是的,不知道这个 js 是如何工作的,但如果我在我的高流量网站中使用它:( 不知道收费
    猜你喜欢
    • 2014-07-01
    • 2018-12-21
    • 2021-12-07
    • 1970-01-01
    • 2011-09-22
    • 1970-01-01
    • 1970-01-01
    • 2011-11-23
    • 1970-01-01
    相关资源
    最近更新 更多