1. <i id='R01Qi'><tr id='R01Qi'><dt id='R01Qi'><q id='R01Qi'><span id='R01Qi'><b id='R01Qi'><form id='R01Qi'><ins id='R01Qi'></ins><ul id='R01Qi'></ul><sub id='R01Qi'></sub></form><legend id='R01Qi'></legend><bdo id='R01Qi'><pre id='R01Qi'><center id='R01Qi'></center></pre></bdo></b><th id='R01Qi'></th></span></q></dt></tr></i><div id='R01Qi'><tfoot id='R01Qi'></tfoot><dl id='R01Qi'><fieldset id='R01Qi'></fieldset></dl></div>
    • <bdo id='R01Qi'></bdo><ul id='R01Qi'></ul>

    <small id='R01Qi'></small><noframes id='R01Qi'>

      <tfoot id='R01Qi'></tfoot>

      <legend id='R01Qi'><style id='R01Qi'><dir id='R01Qi'><q id='R01Qi'></q></dir></style></legend>

      您如何检测网站访问者的国家/地区(特别是美国与否)?

      How do you detect a website visitor#39;s country (Specifically, US or not)?(您如何检测网站访问者的国家/地区(特别是美国与否)?)
    1. <i id='SfrUc'><tr id='SfrUc'><dt id='SfrUc'><q id='SfrUc'><span id='SfrUc'><b id='SfrUc'><form id='SfrUc'><ins id='SfrUc'></ins><ul id='SfrUc'></ul><sub id='SfrUc'></sub></form><legend id='SfrUc'></legend><bdo id='SfrUc'><pre id='SfrUc'><center id='SfrUc'></center></pre></bdo></b><th id='SfrUc'></th></span></q></dt></tr></i><div id='SfrUc'><tfoot id='SfrUc'></tfoot><dl id='SfrUc'><fieldset id='SfrUc'></fieldset></dl></div>
        <tbody id='SfrUc'></tbody>

          <legend id='SfrUc'><style id='SfrUc'><dir id='SfrUc'><q id='SfrUc'></q></dir></style></legend>

          <small id='SfrUc'></small><noframes id='SfrUc'>

              • <bdo id='SfrUc'></bdo><ul id='SfrUc'></ul>

              • <tfoot id='SfrUc'></tfoot>
                本文介绍了您如何检测网站访问者的国家/地区(特别是美国与否)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我需要为访问我网站的美国和非美国访问者显示不同的链接.这只是为了方便起见,所以我不是在寻找超高的准确性,而且安全或欺骗不是问题.

                I need to show different links for US and non-US visitors to my site. This is for convenience only, so I am not looking for a super-high degree of accuracy, and security or spoofing are not a concern.

                我知道有地理定位服务和列表,但这似乎有点过头了,因为我只需要(大致)确定此人是否在美国.

                I know there are geotargeting services and lists, but this seems like overkill since I only need to determine (roughly) if the person is in the US or not.

                我正在考虑使用 JavaScript 来获取用户的时区,但这似乎只给出了偏移量,因此加拿大、墨西哥和南美的用户将具有与美国用户相同的价值.

                I was thinking about using JavaScript to get the user's timezone, but this appears to only give the offset, so users in Canada, Mexico, and South America would have the same value as people in the US.

                除了获取 IP 地址并进行查找之外,还有其他可用的 JavaScript 或 PHP 信息吗?

                Are there any other bits of information available either in JavaScript, or PHP, short of grabbing the IP address and doing a lookup, to determine this?

                推荐答案

                有一些免费服务可以让您从客户端进行基于国家和 ip 的地理定位.

                There are some free services out there that let you make country and ip-based geolocalization from the client-side.

                我用过wipmania免费的JSONP服务,用起来真的很简单:

                I've used the wipmania free JSONP service, it's really simple to use:

                <script type="text/javascript">
                  // plain JavaScript example
                  function jsonpCallback(data) { 
                    alert('Latitude: ' + data.latitude + 
                          '
                Longitude: ' + data.longitude + 
                          '
                Country: ' + data.address.country); 
                  }
                </script>
                <script src="http://api.wipmania.com/jsonp?callback=jsonpCallback"
                        type="text/javascript"></script>
                

                或者,如果您使用支持 JSONP 的框架,例如 jQuery,您可以:

                Or if you use a framework that supports JSONP, like jQuery you can:

                // jQuery example
                $.getJSON('http://api.wipmania.com/jsonp?callback=?', function (data) { 
                  alert('Latitude: ' + data.latitude + 
                        '
                Longitude: ' + data.longitude + 
                        '
                Country: ' + data.address.country); 
                });
                

                检查上面运行的代码段这里.

                Check the above snippet running here.

                这篇关于您如何检测网站访问者的国家/地区(特别是美国与否)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)
              • <small id='2QkRw'></small><noframes id='2QkRw'>

                <legend id='2QkRw'><style id='2QkRw'><dir id='2QkRw'><q id='2QkRw'></q></dir></style></legend>

                    <tbody id='2QkRw'></tbody>

                    <bdo id='2QkRw'></bdo><ul id='2QkRw'></ul>
                    • <i id='2QkRw'><tr id='2QkRw'><dt id='2QkRw'><q id='2QkRw'><span id='2QkRw'><b id='2QkRw'><form id='2QkRw'><ins id='2QkRw'></ins><ul id='2QkRw'></ul><sub id='2QkRw'></sub></form><legend id='2QkRw'></legend><bdo id='2QkRw'><pre id='2QkRw'><center id='2QkRw'></center></pre></bdo></b><th id='2QkRw'></th></span></q></dt></tr></i><div id='2QkRw'><tfoot id='2QkRw'></tfoot><dl id='2QkRw'><fieldset id='2QkRw'></fieldset></dl></div>

                        <tfoot id='2QkRw'></tfoot>