<output id="qn6qe"></output>

    1. <output id="qn6qe"><tt id="qn6qe"></tt></output>
    2. <strike id="qn6qe"></strike>

      亚洲 日本 欧洲 欧美 视频,日韩中文字幕有码av,一本一道av中文字幕无码,国产线播放免费人成视频播放,人妻少妇偷人无码视频,日夜啪啪一区二区三区,国产尤物精品自在拍视频首页,久热这里只有精品12

      淺析Web數(shù)據(jù)存儲(chǔ)-Cookie、UserData、SessionStorage、WebSqlDatabase

      Cookie

      它是標(biāo)準(zhǔn)的客戶端瀏覽器狀態(tài)保存方式,可能在瀏覽器誕生不久就有Cookie了,為什么需要Cookie 這個(gè)東東?由于HTTP協(xié)議沒(méi)有狀態(tài),所以需要一個(gè)標(biāo)志/存儲(chǔ)來(lái)記錄客戶瀏覽器當(dāng)前的狀態(tài),保證客戶瀏覽器和服務(wù)器通訊時(shí)可以知道客戶瀏覽器當(dāng)前的狀態(tài)。Cookie就是記錄這個(gè)狀態(tài)的容器,Cookie在每次請(qǐng)求的時(shí)候都被帶回到服務(wù)器,從而保證了Server可以知道瀏覽器當(dāng)前的狀態(tài),由于Cookie會(huì)被帶回到Server,所以Cookie的內(nèi)容不能存太多,最多不能超過(guò)4K,4K 限制的介紹 http://ec.europa.eu/ipg/standards/cookies/index_en.htm
      其中一段內(nèi)容為:

      A browser is only required to store up to 300 cookies overall and maintain only the last 20 from each domain. The maximum size of a cookie is 4K of disk space.

      但是在一些場(chǎng)景下可能需要存儲(chǔ)超過(guò)4K或者更多的數(shù)據(jù),但是這些數(shù)據(jù)不用在每次請(qǐng)求的時(shí)候被帶回到服務(wù)器,只要能在客戶的瀏覽器上保存住,并且可以方便的被Javascript讀寫就可以了,這種需求尤為在中大型RIA的應(yīng)用場(chǎng)景下更加的迫切,部分?jǐn)?shù)據(jù)放在客戶瀏覽器,節(jié)約帶寬,提高瀏覽速度。HTML5標(biāo)準(zhǔn)已經(jīng)替我們想到了滿足這種需求的方案:sessionStorage , webSqlDatabase, 微軟的IE 有 userData 方案。


      userData
      微軟對(duì)USERDATA的介紹: http://msdn2.microsoft.com/en-us/library/ms531424(VS.85).aspx
      其中一段內(nèi)容為:

      Security Alert:For security reasons, a UserData store is available only in the same directory and with the same protocol used to persist the store.
      Security Alert:Using this behavior incorrectly can compromise the security of your application. Data in a UserData store is not encrypted and therefore not secure. Any application that has access to the drive where UserData is saved has access to the data. Therefore, it is recommended that you not persist sensitive data like credit card numbers. For more information, see Security Considerations: DHTML and Default Behaviors.
      ……
      The userData behavior persists data across sessions, using one UserData store for each object. The UserData store is persisted in the cache using the save and load methods. Once the UserData store has been saved, it can be reloaded even if Microsoft Internet Explorer has been closed and reopened.
      Setting the userData behavior class on the html, head, title, or style object causes an error when the save or load method is called.

       

      userData可以在同目錄同協(xié)議下相互訪問(wèn),長(zhǎng)期存儲(chǔ)在客戶機(jī)器上。最大存儲(chǔ)空間也增大了很多。userData需要綁定到一個(gè)Dom元素上使用。在userData的method中有removeAttribute方法。經(jīng)過(guò)測(cè)試代碼發(fā)現(xiàn)removeAttribute方法好像不是很管用,需要使用像cookie過(guò)期的方式,才可以徹底的刪除一個(gè)userData Attribute。
      http://www.itwen.com/04web/11skill/skill20060918/60588.html 中介紹說(shuō)userData存儲(chǔ)在X:\Documents and Settings\當(dāng)前用戶\UserData\ 目錄下。具體細(xì)節(jié)MS在userData說(shuō)明文檔中沒(méi)有具體說(shuō)明。


      sessionStorage
      HTML5 標(biāo)準(zhǔn)對(duì) sessionStorage的介紹: http://www.whatwg.org/specs/web-apps/current-work/
      其中對(duì) sessionStorage 的介紹:

      This specification introduces two related mechanisms, similar to HTTP session cookies [RFC2965], for storing structured data on the client side.
      The first is designed for scenarios where the user is carrying out a single transaction, but could be carrying out multiple transactions in different windows at the same time.
      Cookies dont really handle this case well. For example, a user could be buying plane tickets in two different windows, using the same site. If the site used cookies to keep track of which ticket the user was buying, then as the user clicked from page to page in both windows, the ticket currently being purchased would "leak" from one window to the other, potentially causing the user to buy two tickets for the same flight without really noticing.
      To address this, this specification introduces the sessionStorage DOM attribute. Sites can add data to the session storage, and it will be accessible to any page from that origin opened in that window.

      Html5 sessionStorage Demo: http://html5demos.com/storage
      下面是根據(jù) http://www.blogjava.net/emu/archive/2006/10/04/73385.html 中提到的IE FF 兼容userData的測(cè)試代碼:

       

      function isIE() {
      return !!document.all;
      }
      
      function initUserData() {
      if (isIE()) document.documentElement.addBehavior("#default#userdata");
      }
      
      function saveUserData(key, value) {
      var ex;
      if (isIE()) {
      //IE
      with (document.documentElement) try {
      load(key);
      setAttribute("value", value);
      save(key);
      return getAttribute("value");
      } catch (ex) {
      alert(ex.message)
      }
      } else if (window.sessionStorage) {
      //FF 2.0+
      try {
      sessionStorage.setItem(key, value)
      } catch (ex) {
      alert(ex);
      }
      } else {
      alert("Error occured in user data saving. your browser do not support user data.");
      }
      }
      
      function loadUserData(key) {
      var ex;
      if (isIE()) {
      //IE 
      with (document.documentElement) try {
      load(key);
      return getAttribute("value");
      } catch (ex) {
      alert(ex.message); return null;
      }
      } else if (window.sessionStorage) {
      //FF 2.0+
      try {
      return sessionStorage.getItem(key)
      } catch (ex) {
      alert(ex)
      }
      } else {
      alert("Error occured in user data loading. your browser do not support user data.")
      }
      }
      function deleteUserData(key) {
      var ex;
      if (isIE()) {
      //IE
      with (document.documentElement) try {
      load(key);
      expires = new Date(315532799000).toUTCString();
      save(key);
      }
      catch (ex) {
      alert(ex.message);
      }
      } else if (window.sessionStorage) {
      //FF 2.0+
      try {
      sessionStorage.removeItem(key)
      } catch (ex) {
      alert(ex)
      }
      } else {
      alert("Error occured in user data deleting. your browser do not support user data.")
      }
      } 

       

      userData和sessionStorage共同的特點(diǎn)就是:這兩個(gè)對(duì)象都可以存儲(chǔ)比cookie大的多的多內(nèi)容。并且不會(huì)隨每次請(qǐng)求帶回到服務(wù)器端。但是根據(jù)Html5標(biāo)準(zhǔn)和測(cè)試發(fā)現(xiàn)userData和sessionStorage有很多地方是不同的。

       

      下面是一個(gè)測(cè)試頁(yè)面:

       

      31_110118_jg9ncookieVsStoragegif

       

      其中的 SetInsurance link 會(huì)操作javascript 在IE下用userData寫數(shù)據(jù), 在FF下用sessionStore寫數(shù)據(jù)。在IE下的情況是:關(guān)閉IE或者重啟機(jī)器寫入的值都不會(huì)丟失。在FF下的情況很有意思:在本頁(yè)面寫入的值在本頁(yè)面可以訪問(wèn),在由本頁(yè)面所打開的其它頁(yè)面可以訪問(wèn)。但是就算本頁(yè)面開著,在導(dǎo)航欄里輸入地址,打開本頁(yè)面,存入的值就不能訪問(wèn)了。在本頁(yè)面存入的值,在它的父頁(yè)面(打開這個(gè)頁(yè)面的頁(yè)面)是訪問(wèn)不到的。又看了看Html5標(biāo)準(zhǔn)。sessionStorage 的全名是:Client-side session and persistent storage of name/value pairs 意思估計(jì)是存儲(chǔ)在Client的內(nèi)容是有session 會(huì)話的,存儲(chǔ)的值由session會(huì)話所維系,一旦session會(huì)話中斷或者丟失,存入的值也就隨之消失了。所以當(dāng)頁(yè)面沒(méi)有session(父頁(yè)面,由地址欄打開的頁(yè)面),是取不到值的。當(dāng)FF關(guān)閉或者重啟機(jī)器必然也就取不到值了。


      webSqlDatabase
      webSqlDatabase在HTML5 標(biāo)準(zhǔn)中是非常Cool的一個(gè)東東, 用Javascript寫SQL查詢,數(shù)據(jù)庫(kù)就在瀏覽器里,這在以前幾乎不敢想象。不過(guò)今天Safari, Chrome, Opera 都已經(jīng)支持了,兩個(gè)webSqlDatabase 的 Demo 頁(yè)面: http://html5demos.com/database http://html5demos.com/database-rollback
      W3C 對(duì)WEBSQLDATABASE 的介紹頁(yè)面: http://dev.w3.org/html5/webdatabase/
      WiKi上一個(gè)簡(jiǎn)明的說(shuō)明: http://en.wikipedia.org/wiki/Web_SQL_Database

      From W3C: "...an API for storing data in databases that can be queried using a variant of SQL"
      Web SQL Database is supported by Google Chrome[1], Opera and Safari but will not be implemented by Mozilla(Firefox)[2] who instead propone Indexed Database API access.

      不知道 HTML 5 的 SQLDB 會(huì)被瀏覽器支持的怎么樣, 不過(guò)sessionStorage看上去已經(jīng)可以基本滿足需求了。

       

       

      icon_save 本文實(shí)例代碼

      posted @ 2010-08-05 14:59  葡萄城技術(shù)團(tuán)隊(duì)  閱讀(6678)  評(píng)論(7)    收藏  舉報(bào)
      主站蜘蛛池模板: 亚洲av国产成人精品区| 亚洲精品一区二区动漫| 日产国产一区二区不卡| 无码专区—va亚洲v天堂麻豆| 果冻传媒一区二区天美传媒| 久久久久国产精品人妻| 中文字幕亚洲一区二区三区| 扒开双腿猛进入喷水高潮叫声| 鹤峰县| 日韩中文字幕免费在线观看| 国产精品入口麻豆| 中文字幕亚洲综合久久2020| 精品人妻日韩中文字幕| 98日韩精品人妻一二区| 九九日本黄色精品视频| 狠狠综合久久综合88亚洲| 中文成人无字幕乱码精品区| 无码人妻人妻经典| 中文有无人妻vs无码人妻激烈| 中文熟妇人妻av在线| 少妇人妻偷人偷人精品| 国产自国产自愉自愉免费24区| 又大又紧又粉嫩18p少妇| 实拍女处破www免费看| 性色av一区二区三区精品| 久久91精品牛牛| 无码人妻出轨黑人中文字幕| 欧美高清狂热视频60一70| 亚洲av无码成人精品区一区| 亚洲国产美国产综合一区| 精品人妻中文字幕av| 92成人午夜福利一区二区| 无码加勒比一区二区三区四区| 国偷自产一区二区三区在线视频| 国产av国片精品一区二区| 亚洲Av综合日韩精品久久久| 日韩成人一区二区三区在线观看| 久久无码中文字幕免费影院蜜桃 | 国产精品一区在线蜜臀| 少妇激情a∨一区二区三区| 欧美大胆老熟妇乱子伦视频 |