HTML5¼¼Êõ

±¾µØ´æ´¢Ö®cookie¡¢localStorage¡¢sessionStorage - С¾ý¾ýµÄ²©¿Í

×ÖºÅ+ ×÷ÕߣºH5Ö®¼Ò À´Ô´£ºH5Ö®¼Ò 2017-07-25 10:02 ÎÒÒªÆÀÂÛ( )

Ò»¡¢±¾µØ´æ´¢·ÖΪcookie£¬ÒÔ¼°ÐÂÔöµÄlocalStorageºÍsessionStorage 1¡¢cookie´æ´¢ÔÚ±¾µØ£¬ÈÝÁ¿×î´ó4k£¬ÔÚͬԴµÄhttpÇëÇóʱЯ´ø´«µÝ£¬ËðºÄ´ø¿í£¬¿ÉÉèÖ÷ÃÎÊ·¾¶£¬Ö»ÓдË·¾¶¼°´Ë·¾¶µÄ×Ó·¾¶²ÅÄÜ·ÃÎÊ´Ëcookie£¬ÔÚÉèÖõĹýÆÚʱ¼ä֮ǰÓÐЧ¡£ a¡¢jqueryÉèÖÃcooki

Ò»¡¢±¾µØ´æ´¢·ÖΪcookie£¬ÒÔ¼°ÐÂÔöµÄlocalStorageºÍsessionStorage 1¡¢cookie´æ´¢ÔÚ±¾µØ£¬ÈÝÁ¿×î´ó4k£¬ÔÚͬԴµÄhttpÇëÇóʱЯ´ø´«µÝ£¬ËðºÄ´ø¿í£¬¿ÉÉèÖ÷ÃÎÊ·¾¶£¬Ö»ÓдË·¾¶¼°´Ë·¾¶µÄ×Ó·¾¶²ÅÄÜ·ÃÎÊ´Ëcookie£¬ÔÚÉèÖõĹýÆÚʱ¼ä֮ǰÓÐЧ¡£

a¡¢jqueryÉèÖÃcookie¡£expires¹ýÆÚʱ¼ä

$.cookie("mycookie"£¬"ok"£¬{expires:7£¬path:"http://www.cnblogs.com/"})£»

b¡¢jquery»ñÈ¡cookie

$.cookie("mycookie")£»

2¡¢localStorage´æ´¢ÔÚ±¾µØ£¬ÈÝÁ¿Îª5M»òÕ߸ü´ó£¬²»»áÔÚÇëÇóʱºòЯ´ø´«µÝ£¬ÔÚËùÓÐͬԴ´°¿ÚÖй²Ïí£¬Êý¾ÝÒ»Ö±ÓÐЧ£¬³ý·ÇÈËΪɾ³ý£¬¿É×÷Ϊ³¤ÆÚÊý¾Ý¡£

ÉèÖãº

localStorage.setItem("data"£¬"456")£»»òÕßlocalStorage.data = "456"£»

»ñÈ¡£º

localStorage.getItem("data");»òÕßlocalStorage.data

ɾ³ý£º

localStorage.removeItem("data")

3¡¢sessionStorage´æ´¢ÔÚ±¾µØ£¬ÈÝÁ¿Îª5M»òÕ߸ü´ó£¬²»»áÔÚÇëÇóʱºòЯ´ø´«µÝ£¬ÔÚͬԴµÄµ±Ç°´°¿Ú¹Ø±ÕÇ°ÓÐЧ£¬µ«Ë¢ÐÂÒ³Ãæ»òʹÓá°Ç°½ø¡±¡¢¡°ºóÍË°´Å¥¡±ºósessionStorageÈÔÈ»´æÔÚ¡£

localStorageºÍsessionStorageºÏ³ÆΪWebStorage£¬WebStorageÖ§³Öʼþ֪ͨ»úÖÆ£¬¿ÉÒÔ½«Êý¾Ý¸üеÄ֪ͨ¼àÌýÕߣ¬WebStorageµÄapi½Ó¿ÚʹÓøü·½±ã

×¢£ºiPhoneµÄÎÞºÛä¯ÀÀ²»Ö§³ÖWebStorage,Ö»ÄÜʹÓÃcookie

 

¡¡

1.±¾Õ¾×ñÑ­ÐÐÒµ¹æ·¶£¬ÈκÎתÔصĸå¼þ¶¼»áÃ÷È·±ê×¢×÷ÕߺÍÀ´Ô´£»2.±¾Õ¾µÄÔ­´´ÎÄÕ£¬ÇëתÔØʱÎñ±Ø×¢Ã÷ÎÄÕÂ×÷ÕߺÍÀ´Ô´£¬²»×ðÖØÔ­´´µÄÐÐΪÎÒÃǽ«×·¾¿ÔðÈΣ»3.×÷ÕßͶ¸å¿ÉÄܻᾭÎÒÃDZ༭Ð޸Ļò²¹³ä¡£

Ïà¹ØÎÄÕÂ
  • HTML5 ¡ª Wed SQL ±¾µØÊý¾Ý¿âʾÀý - gdwkong

    HTML5 ¡ª Wed SQL ±¾µØÊý¾Ý¿âʾÀý - gdwkong

    2017-07-23 10:00

  • H5±¾µØ´æ´¢ - ²ËÄñÒ²ÓÐÐÄ

    H5±¾µØ´æ´¢ - ²ËÄñÒ²ÓÐÐÄ

    2017-07-09 16:02

  • Ç°¶ËÈçºÎ½«H5Ò³Ãæ´ò°ü³É±¾µØapp£¿ - zhoulin-circle

    Ç°¶ËÈçºÎ½«H5Ò³Ãæ´ò°ü³É±¾µØapp£¿ - zhoulin-circle

    2017-07-05 08:01

  • ±¾µØ´æ´¢ web storage - һͷҰÂëÅ©

    ±¾µØ´æ´¢ web storage - һͷҰÂëÅ©

    2017-06-21 18:00

ÍøÓѵãÆÀ
¨