久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

    1. <small id='T0DD0'></small><noframes id='T0DD0'>

    2. <i id='T0DD0'><tr id='T0DD0'><dt id='T0DD0'><q id='T0DD0'><span id='T0DD0'><b id='T0DD0'><form id='T0DD0'><ins id='T0DD0'></ins><ul id='T0DD0'></ul><sub id='T0DD0'></sub></form><legend id='T0DD0'></legend><bdo id='T0DD0'><pre id='T0DD0'><center id='T0DD0'></center></pre></bdo></b><th id='T0DD0'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='T0DD0'><tfoot id='T0DD0'></tfoot><dl id='T0DD0'><fieldset id='T0DD0'></fieldset></dl></div>

        • <bdo id='T0DD0'></bdo><ul id='T0DD0'></ul>
        <tfoot id='T0DD0'></tfoot>
        <legend id='T0DD0'><style id='T0DD0'><dir id='T0DD0'><q id='T0DD0'></q></dir></style></legend>
      1. 存儲 HTML5 地理位置數據

        Storing HTML5 geolocation data(存儲 HTML5 地理位置數據)
                  <tbody id='UyXH6'></tbody>
                  <bdo id='UyXH6'></bdo><ul id='UyXH6'></ul>

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

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

                • <legend id='UyXH6'><style id='UyXH6'><dir id='UyXH6'><q id='UyXH6'></q></dir></style></legend>
                  <tfoot id='UyXH6'></tfoot>

                • 本文介紹了存儲 HTML5 地理位置數據的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  如何在 Rails 3 中存儲和處理網站用戶的地理位置(經緯度),以便它檢查我們是否已經在每個頁面請求的用戶會話中保存了這些詳細信息(如果我們沒有保存詳細信息,那么我們應該從瀏覽器請求用戶的位置,然后將這些詳細信息存儲在會話中)?

                  How can I store and process the geolocation (long and lat) of a website user in Rails 3, so that it checks to see if we're already holding those details in a session for that user on every page request (if we're not holding the details, then we should request the user's location from the browser and then store those details in the session)?

                  推薦答案

                  根據您的要求,我想說您實際上并不需要 ajax,因為大部分處理將使用 JS 完成(詢問用戶訪問他們的位置,解析響應等),我會使用 JS 設置一個 cookie,Rails 會看到).

                  Based on your requirements I'd say that you don't actually need ajax, since most of the processing will be done using JS (to ask the user for access to their location, parse the response etc), I'd use JS to set a cookie, which Rails will then see).

                  在您的控制器中

                  def action
                    @lat_lng = cookies[:lat_lng].split("|")
                  end
                  

                  在你看來

                  <%- unless @lat_lng %>
                  <script>
                    getGeoLocation();
                  </script>
                  <%- end %>
                  

                  在您的一個 javascript 文件中

                  function getGeoLocation() {
                    navigator.geolocation.getCurrentPosition(setGeoCookie);
                  }
                  
                  function setGeoCookie(position) {
                    var cookie_val = position.coords.latitude + "|" + position.coords.longitude;
                    document.cookie = "lat_lng=" + escape(cookie_val);
                  }
                  

                  請注意,上述測試都不是為了查看用戶是否擁有支持地理定位的瀏覽器,或者用戶是否已授予(或拒絕)使用其位置的權限,并且該 cookie 將是一個會話 cookie,并且JS 不會測試是否已經設置了 cookie.要在 cookie 上設置更復雜的信息,請查看 http://www.quirksmode.org/js/cookies.html 有關使用 javascript 的 GeoLocation 的更多信息,請參閱 http://diveintohtml5.info/geolocation.html

                  Note that none of the above tests to see if the user has a browser that supports geolocation, or if the user has granted (or denied) permission to use their location, and that the cookie will be a session cookie, and that the JS doesn't test to see if the cookie is already set. To set more complicated information on the cookie take a look at http://www.quirksmode.org/js/cookies.html For more information on GeoLocation using javascript see http://diveintohtml5.info/geolocation.html

                  這篇關于存儲 HTML5 地理位置數據的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  Angular 2 (Ionic 2): intercept ajax requests(Angular 2 (Ionic 2):攔截 ajax 請求)
                  Angular 2 HTTP Progress bar(Angular 2 HTTP 進度條)
                  Printing from an application in IIS to a networked printer on server(從 IIS 中的應用程序打印到服務器上的網絡打印機)
                  angular2 posting XML type request data using HTTP(angular2 使用 HTTP 發布 XML 類型的請求數據)
                  Rounding Lat and Long to Show Approximate Location in Google Maps(舍入經緯度以在 Google 地圖中顯示大致位置)
                  Event not working on dynamically created element(事件不適用于動態創建的元素)

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

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

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

                          • <legend id='kTyig'><style id='kTyig'><dir id='kTyig'><q id='kTyig'></q></dir></style></legend>
                              <tbody id='kTyig'></tbody>
                            主站蜘蛛池模板: 综合天天久久 | 91精品国产一二三 | 国产激情视频 | 国偷自产av一区二区三区 | 日韩成人在线电影 | 国产一区二区在线播放视频 | 日韩精品一二三区 | 黄色国产 | 免费黄色录像视频 | 国产一区二区三区在线看 | 亚洲黄色高清视频 | 日韩在线视频免费观看 | 成人精品一区二区 | 懂色一区二区三区免费观看 | 国产成人精品久久二区二区 | 青娱乐av | 91久久综合亚洲鲁鲁五月天 | 91中文字幕在线 | 亚洲天堂999 | 黄色片免费在线观看 | 亚州精品天堂中文字幕 | 亚洲久在线 | 午夜成人免费视频 | 成人免费观看男女羞羞视频 | 一区二区久久 | 日韩电影免费在线观看中文字幕 | 亚洲精品欧美 | 最新中文字幕在线 | 国产91丝袜在线熟 | 综合二区 | 91视视频在线观看入口直接观看 | 中文av在线播放 | 天天躁天天操 | 国产中文在线 | 亚洲97| 中文字幕一区二区在线观看 | 亚洲人成免费 | 亚洲国产一区二区三区四区 | 视频一区二区三区中文字幕 | 日本xx视频免费观看 | 精品亚洲第一 |