{"id":142,"date":"2013-06-03T22:44:05","date_gmt":"2013-06-03T14:44:05","guid":{"rendered":"http:\/\/weitaoc.com\/?p=142"},"modified":"2013-06-03T22:45:08","modified_gmt":"2013-06-03T14:45:08","slug":"%e5%85%b3%e4%ba%8estore-js%e7%9a%84%e4%b8%80%e4%b8%aabug","status":"publish","type":"post","link":"http:\/\/weitaoc.com\/?p=142","title":{"rendered":"\u5173\u4e8estore.js\u7684\u4e00\u4e2aBUG"},"content":{"rendered":"<p>store.js \u662f\u4e00\u4e2a\u5b9e\u73b0\u4e86\u6d4f\u89c8\u5668\u7684\u672c\u5730\u5b58\u50a8\u7684 JavaScript \u5c01\u88c5 API\uff0c\u4e0d\u662f\u901a\u8fc7 Cookie \u548c Flash \u6280\u672f\u5b9e\u73b0\uff0c\u800c\u662f\u4f7f\u7528 localStorage\u3001globalStorage \u548c userData \u884c\u4e3a\u3002<\/p>\n<p>\u4e5f\u5c31\u662f\u8bf4\u8fd9\u4e2a\u5c01\u88c5\u7c7b\u662f\u517c\u5bb9\u73b0\u5728\u7edd\u5927\u591a\u6570\u6d4f\u89c8\u5668\u7684\u4e00\u4e2a\u5728\u7ebf\u6570\u636e\u5b58\u50a8\u65b9\u6848\u3002\u4f46\u662f\u6709\u4e00\u4e2a\u95ee\u9898\u5374\u662f\u4e0d\u5f97\u4e0d\u63d0\u3002<\/p>\n<p>\u7b14\u8005\u4eb2\u6d4b\uff0c\u5728IE7\u4e0b\u6548\u679c\u5e76\u4e0d\u597d\uff0c\u5f53\u7136\u662f\u6709\u573a\u666f\u7684\uff0c\u6211\u4eec\u51c6\u5907\u4e24\u4e2a\u9875\u9762\u540c\u65f6\u8c03\u7528\u4e00\u4e2astore.js\uff0cA\u9875\u9762\u53d6\u5f97userdata\u503c\uff0cB\u9875\u9762\u5b58\u50a8userdata\u503c\u3002\u6211\u4eec\u4f1a\u53d1\u73b0\uff0c\u6211\u4eec\u7528\u540c\u4e00\u4e2a\u6d4f\u89c8\u5668\u6253\u5f00\u8fd9\u4e24\u4e2a\u9875\u9762\u540e\uff0c\u4f7f\u7528B\u5b58\u50a8\uff0c\u4f46\u662fA\u83b7\u53d6\u4e0d\u5230\u503c\uff0c\u4f46\u662f\u5237\u65b0\u4e00\u4e0bA\u9875\u9762\uff0c\u5c31\u53ef\u4ee5\u53d6\u5230\u503c\u4e86\u3002<\/p>\n<p>\u6211\u4eec\u77e5\u9053userdata\uff0c<\/p>\n<p>\u5728XP\u4e0b\uff0c\u4e00\u822c\u4f4d\u4e8eC:\\Documents and Settings\\\u7528\u6237\u540d\\UserData\uff0c\u6709\u4e9b\u65f6\u5019\u4f1a\u5728C:\\Documents and Settings\\\u7528\u6237\u540d\\Application Data\\Microsoft\\Internet Explorer\\UserData\u3002<\/p>\n<p>\u5728Vista\u4e0b\uff0c\u4f4d\u4e8eC:\\Users\\\u7528\u6237\u540d\\AppData\\Roaming\\Microsoft\\Internet Explorer\\UserData\u3002<\/p>\n<p>\u5f53\u6211\u4eec\u53bb\u67e5\u627e\u8fd9\u4e2a\u6587\u4ef6\u7684\u65f6\u5019\uff0c\u53d1\u73b0\u67094\u4e2a\u6587\u4ef6\u5939\uff0c\u548c\u4e00\u4e2a\u6587\u4ef6\uff0c\u5f53\u6211\u4eec\u8c03\u7528B\u9875\u9762\u7684\u65f6\u5019\uff0c\u4e0d\u5237\u65b0A\u9875\u9762\uff0cIE\u4f1a\u5728\u4e00\u4e2a\u6587\u4ef6\u5939\u91cc\u9762\u66f4\u65b0\u90a3\u4e2a\u6587\u4ef6\uff0c\u4f46\u662f\u5f53\u6211\u4eec\u5237\u65b0A\u9875\u9762\u7684\u65f6\u5019\uff0cIE\u968f\u673a\u5728\u4e00\u4e2a\u6587\u4ef6\u91cc\u9762\u751f\u6210\u4e86\u6587\u4ef6\uff0c\u5e76\u4e0d\u5728\u539f\u6765\u7684\u6587\u4ef6\u5939\u91cc\u9762\u3002<\/p>\n<p>\u6240\u4ee5\u63a8\u6d4b\uff0cIE\uff0c\u6700\u8d77\u7801\u5728IE7\u4e0b\u9762\uff0cuserdata\u662f\u72ec\u5360\u7684\uff0c\u5f53\u4e00\u4e2a\u9875\u9762\u8c03\u7528\u540e\uff0c\u5c31\u4f1a\u5bf9\u8fd9\u4e2a\u6587\u4ef6\u72ec\u5360\uff0c\u53ea\u5141\u8bb8\u8bfb\uff0c\u4e0d\u5141\u8bb8\u5199\uff0c\u4ee5\u81f3B\u9875\u9762\u4e0d\u5f97\u4e0d\u5728\u5176\u4ed6\u7684\u6587\u4ef6\u5939\u518d\u6b21\u65b0\u5efa\u4e00\u4e2a\u5b58\u50a8\u6587\u4ef6\u3002\u8fd9\u4e2a\u5b58\u50a8\u6587\u4ef6\u590d\u5236\u4e86\u88ab\u5360\u7528\u6587\u4ef6\u7684\u5185\u5bb9\uff0c\u540c\u65f6\u65b0\u589e\u4e86\u6700\u65b0\u7684\u6570\u636e\uff0c\u4f46\u662fA\u9875\u9762\u5374\u65e0\u6cd5\u8bfb\u5230\uff0c\u56e0\u4e3a\u5b83\u4efb\u7136\u5360\u7528\u7740\u4ee5\u524d\u7684\u90a3\u4e2a\u6587\u4ef6\u3002<\/p>\n<p>\u6211\u4eec\u770b\u770bstore.js\u7684\u6e90\u7801\uff0c\u5176\u4e2d\u6709\u4e00\u6bb5\uff1a<\/p>\n<div class=\"codecolorer-container javascript geshi\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/>2<br \/>3<br \/>4<br \/>5<br \/>6<br \/>7<br \/>8<br \/>9<br \/>10<br \/><\/div><\/td><td><div class=\"javascript codecolorer\" style=\"white-space:nowrap\"><span style=\"color: #000066; font-weight: bold;\">function<\/span> getStorage<span style=\"color: #009900;\">&#40;<\/span><span style=\"color: #009900;\">&#41;<\/span> <span style=\"color: #009900;\">&#123;<\/span><br \/>\n<span style=\"color: #000066; font-weight: bold;\">if<\/span> <span style=\"color: #009900;\">&#40;<\/span>storage<span style=\"color: #009900;\">&#41;<\/span> <span style=\"color: #009900;\">&#123;<\/span> <span style=\"color: #000066; font-weight: bold;\">return<\/span> storage <span style=\"color: #009900;\">&#125;<\/span><br \/>\nstorage <span style=\"color: #339933;\">=<\/span> doc.<span style=\"color: #660066;\">body<\/span>.<span style=\"color: #660066;\">appendChild<\/span><span style=\"color: #009900;\">&#40;<\/span>doc.<span style=\"color: #660066;\">createElement<\/span><span style=\"color: #009900;\">&#40;<\/span><span style=\"color: #3366CC;\">'div'<\/span><span style=\"color: #009900;\">&#41;<\/span><span style=\"color: #009900;\">&#41;<\/span><span style=\"color: #339933;\">;<\/span><br \/>\nstorage.<span style=\"color: #660066;\">style<\/span>.<span style=\"color: #660066;\">display<\/span> <span style=\"color: #339933;\">=<\/span> <span style=\"color: #3366CC;\">'none'<\/span><span style=\"color: #339933;\">;<\/span><br \/>\n<span style=\"color: #006600; font-style: italic;\">\/\/ See http:\/\/msdn.microsoft.com\/en-us\/library\/ms531081(v=VS.85).aspx<\/span><br \/>\n<span style=\"color: #006600; font-style: italic;\">\/\/ and http:\/\/msdn.microsoft.com\/en-us\/library\/ms531424(v=VS.85).aspx<\/span><br \/>\nstorage.<span style=\"color: #660066;\">addBehavior<\/span><span style=\"color: #009900;\">&#40;<\/span><span style=\"color: #3366CC;\">'#default#userData'<\/span><span style=\"color: #009900;\">&#41;<\/span><span style=\"color: #339933;\">;<\/span><br \/>\nstorage.<span style=\"color: #660066;\">load<\/span><span style=\"color: #009900;\">&#40;<\/span>localStorageName<span style=\"color: #009900;\">&#41;<\/span><span style=\"color: #339933;\">;<\/span><br \/>\n<span style=\"color: #000066; font-weight: bold;\">return<\/span> storage<span style=\"color: #339933;\">;<\/span><br \/>\n<span style=\"color: #009900;\">&#125;<\/span><\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p>\u6709\u70b9\u7c7b\u4f3cjava\u7684\u5355\u4f8b\uff0c\u4f46\u662f\u4e5f\u6b63\u662f\u8fd9\u91cc\u9020\u6210\u4e86BUG\uff0c\u5b83\u4f1a\u8ba9IE\u5728\u540c\u4e00\u4e2a\u9875\u9762\u751f\u547d\u5468\u671f\u91cc\u9762\u53ea\u521d\u59cb\u5316\u4e00\u4e2astorage\uff0c\u964d\u4f4e\u4e86\u9875\u9762\u6027\u80fd\u7684\u6d88\u8017\uff0c\u5374\u5e26\u6765\u517c\u5bb9\u6027\u7684\u7f3a\u9677\uff0c\u8fd9\u91cc\uff0c\u6211\u4eec\u53ea\u9700\u8981\u505a\u70b9\u5c0f\u624b\u672f\u5c31\u884c\u4e86\u3002<\/p>\n<div class=\"codecolorer-container javascript geshi\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/>2<br \/>3<br \/>4<br \/>5<br \/>6<br \/>7<br \/>8<br \/>9<br \/>10<br \/>11<br \/>12<br \/>13<br \/><\/div><\/td><td><div class=\"javascript codecolorer\" style=\"white-space:nowrap\"><span style=\"color: #000066; font-weight: bold;\">function<\/span> getStorage<span style=\"color: #009900;\">&#40;<\/span><span style=\"color: #009900;\">&#41;<\/span> <span style=\"color: #009900;\">&#123;<\/span><br \/>\n<span style=\"color: #000066; font-weight: bold;\">if<\/span><span style=\"color: #009900;\">&#40;<\/span><span style=\"color: #339933;\">!<\/span><span style=\"color: #009900;\">&#40;<\/span><span style=\"color: #339933;\">-<\/span><span style=\"color: #009900;\">&#91;<\/span><span style=\"color: #CC0000;\">1<\/span><span style=\"color: #339933;\">,<\/span><span style=\"color: #009900;\">&#93;<\/span><span style=\"color: #009900;\">&#41;<\/span><span style=\"color: #009900;\">&#41;<\/span><span style=\"color: #009900;\">&#123;<\/span><br \/>\n<span style=\"color: #000066; font-weight: bold;\">if<\/span> <span style=\"color: #009900;\">&#40;<\/span>storage<span style=\"color: #009900;\">&#41;<\/span> <span style=\"color: #009900;\">&#123;<\/span> <span style=\"color: #000066; font-weight: bold;\">return<\/span> storage <span style=\"color: #009900;\">&#125;<\/span> \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0<span style=\"color: #006600; font-style: italic;\">\/\/\u5f53\u6d4f\u89c8\u5668\u4e0d\u4e3aIE\u7684\u65f6\u5019\uff0c\u5355\u4f8bstorage<\/span><br \/>\n<br \/>\n<span style=\"color: #009900;\">&#125;<\/span><br \/>\nstorage <span style=\"color: #339933;\">=<\/span> doc.<span style=\"color: #660066;\">body<\/span>.<span style=\"color: #660066;\">appendChild<\/span><span style=\"color: #009900;\">&#40;<\/span>doc.<span style=\"color: #660066;\">createElement<\/span><span style=\"color: #009900;\">&#40;<\/span><span style=\"color: #3366CC;\">'div'<\/span><span style=\"color: #009900;\">&#41;<\/span><span style=\"color: #009900;\">&#41;<\/span><span style=\"color: #339933;\">;<\/span><br \/>\nstorage.<span style=\"color: #660066;\">style<\/span>.<span style=\"color: #660066;\">display<\/span> <span style=\"color: #339933;\">=<\/span> <span style=\"color: #3366CC;\">'none'<\/span><span style=\"color: #339933;\">;<\/span><br \/>\n<span style=\"color: #006600; font-style: italic;\">\/\/ See http:\/\/msdn.microsoft.com\/en-us\/library\/ms531081(v=VS.85).aspx<\/span><br \/>\n<span style=\"color: #006600; font-style: italic;\">\/\/ and http:\/\/msdn.microsoft.com\/en-us\/library\/ms531424(v=VS.85).aspx<\/span><br \/>\nstorage.<span style=\"color: #660066;\">addBehavior<\/span><span style=\"color: #009900;\">&#40;<\/span><span style=\"color: #3366CC;\">'#default#userData'<\/span><span style=\"color: #009900;\">&#41;<\/span><span style=\"color: #339933;\">;<\/span><br \/>\nstorage.<span style=\"color: #660066;\">load<\/span><span style=\"color: #009900;\">&#40;<\/span>localStorageName<span style=\"color: #009900;\">&#41;<\/span><span style=\"color: #339933;\">;<\/span><br \/>\n<span style=\"color: #000066; font-weight: bold;\">return<\/span> storage<span style=\"color: #339933;\">;<\/span><br \/>\n<span style=\"color: #009900;\">&#125;<\/span><\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<div id=\"attachment_49\" style=\"width: 182px\" class=\"wp-caption alignnone\"><a href=\"http:\/\/weitaoc.com\/archives\/48\/attachment\/4\" rel=\"attachment wp-att-49\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-49\" class=\"size-full wp-image-49\" alt=\"js\" src=\"http:\/\/weitaoc.com\/wp-content\/uploads\/2013\/01\/4.jpg\" width=\"172\" height=\"121\" \/><\/a><p id=\"caption-attachment-49\" class=\"wp-caption-text\">js<\/p><\/div>\n<p>\u8f6c\u8f7d\u8bf7\u6ce8\u660e\uff1a<a href=\"http:\/\/weitaoc.com\">\u8ff7\u8def\u7684\u8001\u9f20<\/a> &raquo; <a href=\"http:\/\/weitaoc.com\/?p=142\">\u5173\u4e8estore.js\u7684\u4e00\u4e2aBUG<\/a><\/p>","protected":false},"excerpt":{"rendered":"<p>store.js \u662f\u4e00\u4e2a\u5b9e\u73b0\u4e86\u6d4f\u89c8\u5668\u7684\u672c\u5730\u5b58\u50a8\u7684 JavaScript \u5c01\u88c5 API\uff0c\u4e0d\u662f\u901a\u8fc7 Cookie \u548c Flash \u6280\u672f\u5b9e\u73b0\uff0c\u800c\u662f\u4f7f\u7528 localStorage\u3001globalStorage \u548c userData \u884c\u4e3a\u3002 \u4e5f\u5c31\u662f\u8bf4\u8fd9\u4e2a\u5c01\u88c5\u7c7b\u662f [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[14],"tags":[15,36],"class_list":["post-142","post","type-post","status-publish","format-standard","hentry","category-front-end","tag-js","tag-store-js"],"views":3481,"_links":{"self":[{"href":"http:\/\/weitaoc.com\/index.php?rest_route=\/wp\/v2\/posts\/142","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/weitaoc.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/weitaoc.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/weitaoc.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/weitaoc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=142"}],"version-history":[{"count":0,"href":"http:\/\/weitaoc.com\/index.php?rest_route=\/wp\/v2\/posts\/142\/revisions"}],"wp:attachment":[{"href":"http:\/\/weitaoc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=142"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/weitaoc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=142"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/weitaoc.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=142"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}