1、地理位置( geolocation ): navigator.geolocation對象: 一、單次請求: //navigator.geolocation.getCurrentPosition( function(res){ //請求成功函數: (調用方式:res.coords.longitude) 經度:coords.longitude 維度:coords.latitude 精準度:coords.accuracy 海拔:coords.altitude 海拔精準度:coords.altitudeAcuracy 行進方向:coords.heading 地面速度:coords.speed 時間戳: new Date(position.timestamp); }, function(err){ //請求失敗: console.log(err.code); //0: 不包括其餘編號中的錯誤 1:用戶拒絕共享位置 2:嘗試獲取用戶信息,失敗了 3:設置了timeout值,獲取位置超時了 },{ //數據收集方式: enableHighAcuracy : 更精確的查找,默認false timeout : 獲取位置容許最長時間,默認infinity maximumAge : 位置能夠緩存的最大時間,默認0 }); 二、屢次定位請求: //watchPosition(); --> 屢次定位請求 --- 移動設備有用,位置改變時觸發 --- 配置參數:frequency 更新的頻率 //clearWatch(); --> 關閉跟新請求 --navigator.geolocation.clearWatch(); 2、本地存儲( storage ): 1.cookie: 一個域名400k大小 每次使用都要請求服務器 數據共享 2.storege: ( 存儲限制5M ) a、sessionStorage:(臨時存儲,頁面關閉消失,數據不共享) b、localStorage:(永久存儲,可手動刪除,數據共享) c、API: (1)、setItem(); 設置存儲 (2)、getItem(); 獲取存儲 (3)、removeItem(); 刪除存儲 (4)、clear(); 清楚全部存儲 (5)、storage //事件:當有數據修改或刪除就會觸發(修改的窗口不會觸發storage事件) -->storage事件中的ev對象中存儲以下數據: *ev.key: 修改或刪除的可key值 若是調用clear()則爲null *ev.newValue: 新設置的值 若是調用removeStorage(),key爲null *ev.olValue: 改變前的值 *ev.storageArea: 當前的storage對象(中存儲的全部的值) *ev.url: 出發該腳本變化的文檔 注:session同學口才能夠,例如:iframe操做