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

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

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

      <tfoot id='S9BYS'></tfoot>

    2. 有没有一种简单的方法可以确定用户在哪个半球

      时间:2023-09-06

        • <legend id='ichYl'><style id='ichYl'><dir id='ichYl'><q id='ichYl'></q></dir></style></legend>
        • <small id='ichYl'></small><noframes id='ichYl'>

            <bdo id='ichYl'></bdo><ul id='ichYl'></ul>

              <tfoot id='ichYl'></tfoot>

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

                本文介绍了有没有一种简单的方法可以确定用户在哪个半球?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                我正在开展一个包含季节性内容的项目,我们正在考虑确定用户的位置,以确定适合他们的季节.这样做的明显方法是对他们的 IP 进行地理定位,然后获取纬度.> 0 是北半球,<0 是南方.

                I'm working on a project which includes seasonal content, and we're thinking of determining the user's location to work out what season it is for them. The obvious way of doing this is to Geo-locate their IP, then grab the latitude. > 0 is Northern hemisphere, and < 0 is Southern.

                我很高兴这样做 - 虽然将 IP 精确定位到确切位置似乎有点浪费,只是为了确定它们在地球的哪一半 - 但我想我会扔掉它以防万一有人有任何可能缩短流程的技巧.

                I'm happy to go that way - though it seems a bit of a waste to pinpoint an IP to an exact location, just to determine which half of the planet they're on - but I thought I'd throw it out there in case anyone has any tricks which might shortcut the process.

                请求标头,可以在客户端用 JS 提取的东西,很容易获得 - 我只是认为它没有任何帮助.

                Request headers, stuff that can be extracted with JS on the client, it's all easy enough to get - I just don't think any of it helps.

                推荐答案

                我先看看客户的时钟——如果客户的日历中存在夏令时,你可以判断他是在赤道以北还是以南.

                I'd first check the client's clock- if daylight savings exists in the client's calendar, you can tell if he is north or south of the equator.

                如果没有dst信息,可以使用geolocation,

                if there is no dst information, you can use geolocation,

                或者询问用户是否在赤道以南...

                or ask the user if he is south of the equator...

                window.whatHemisphere= (function(){
                    var y= new Date().getFullYear();
                    if(y.getTimezoneOffset()==undefined) return null;
                    var jan= -(new Date(y, 0, 1, 0, 0, 0, 0).getTimezoneOffset()),
                    jul= -(new Date(y, 6, 1, 0, 0, 0, 0).getTimezoneOffset()),
                    diff= jan-jul;
                    if(diff> 0) return 'N';
                    if(diff< 0) return 'S'
                    return null;
                })()
                

                这篇关于有没有一种简单的方法可以确定用户在哪个半球?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:如何在 Nodejs 中查找所有用户的 geoip 位置 下一篇:js 地理定位但没有提示 - 可能吗?

                相关文章

                最新文章

                <tfoot id='uDYae'></tfoot>

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

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

                      <bdo id='uDYae'></bdo><ul id='uDYae'></ul>