{"id":1138,"date":"2011-11-22T09:48:00","date_gmt":"2011-11-22T01:48:00","guid":{"rendered":"\/?p=1138"},"modified":"2011-11-22T09:48:00","modified_gmt":"2011-11-22T09:48:00","slug":"1138","status":"publish","type":"post","link":"https:\/\/blog.vimge.com\/archives\/other\/1138.html","title":{"rendered":"\u8de8\u57df\u8d44\u6e90\u5171\u4eab\u768410\u79cd\u65b9\u5f0f"},"content":{"rendered":"

\u8de8\u57df\u95ee\u9898\u7b97\u662f\u8001\u751f\u957f\u8c08\u7684\u4e86\uff0c\u4e0b\u9762\u662f\u53e3\u7891UDE\u56e2\u961f\u6574\u7406\u7684\u8d44\u6599\uff0c\u6709\u4ee3\u7801\u6f14\u793a\u53ef\u4f9b\u4e0b\u8f7d \u3002<\/p>\n<\/p>\n

\u540c\u6e90\u7b56\u7565<\/span><\/h3>\n<\/p>\n

\u5728\u5ba2\u6237\u7aef\u7f16\u7a0b\u8bed\u8a00\u4e2d\uff0c\u5982JavaScript\u548cActionScript\uff0c\u540c\u6e90\u7b56\u7565\u662f\u4e00\u4e2a\u5f88\u91cd\u8981\u7684\u5b89\u5168\u7406\u5ff5\uff0c\u5b83\u5728\u4fdd\u8bc1\u6570\u636e\u7684\u5b89\u5168\u6027\u65b9\u9762\u6709\u7740\u91cd\u8981\u7684\u610f\u4e49\u3002\u540c\u6e90\u7b56\u7565\u89c4\u5b9a\u8de8\u57df\u4e4b\u95f4\u7684\u811a\u672c\u662f\u9694\u79bb\u7684\uff0c\u4e00\u4e2a\u57df\u7684\u811a\u672c\u4e0d\u80fd\u8bbf\u95ee\u548c\u64cd\u4f5c\u53e6\u5916\u4e00\u4e2a\u57df\u7684\u7edd\u5927\u90e8\u5206\u5c5e\u6027\u548c\u65b9\u6cd5\u3002\u90a3\u4e48\u4ec0\u4e48\u53eb\u76f8\u540c\u57df\uff0c\u4ec0\u4e48\u53eb\u4e0d\u540c\u7684\u57df\u5462\uff1f\u5f53\u4e24\u4e2a\u57df\u5177\u6709\u76f8\u540c\u7684\u534f\u8bae(\u5982http), \u76f8\u540c\u7684\u7aef\u53e3(\u598280)\uff0c\u76f8\u540c\u7684host\uff08\u5982www.example.org)\uff0c\u90a3\u4e48\u6211\u4eec\u5c31\u53ef\u4ee5\u8ba4\u4e3a\u5b83\u4eec\u662f\u76f8\u540c\u7684\u57df\u3002\u6bd4\u5982http:\/\/www.example.org\/index.html\u548chttp:\/\/www.example.org\/sub\/index.html\u662f\u540c\u57df\uff0c\u800chttp:\/\/www.example.org, https:\/\/www.example.org, http:\/\/www.example.org:8080, http:\/\/sub.example.org\u4e2d\u7684\u4efb\u4f55\u4e24\u4e2a\u90fd\u5c06\u6784\u6210\u8de8\u57df\u3002\u540c\u6e90\u7b56\u7565\u8fd8\u5e94\u8be5\u5bf9\u4e00\u4e9b\u7279\u6b8a\u60c5\u51b5\u505a\u5904\u7406\uff0c\u6bd4\u5982\u9650\u5236file\u534f\u8bae\u4e0b\u811a\u672c\u7684\u8bbf\u95ee\u6743\u9650\u3002\u672c\u5730\u7684HTML\u6587\u4ef6\u5728\u6d4f\u89c8\u5668\u4e2d\u662f\u901a\u8fc7file\u534f\u8bae\u6253\u5f00\u7684\uff0c\u5982\u679c\u811a\u672c\u80fd\u901a\u8fc7file\u534f\u8bae\u8bbf\u95ee\u5230\u786c\u76d8\u4e0a\u5176\u5b83\u4efb\u610f\u6587\u4ef6\uff0c\u5c31\u4f1a\u51fa\u73b0\u5b89\u5168\u9690\u60a3\uff0c\u76ee\u524dIE8\u8fd8\u6709\u8fd9\u6837\u7684\u9690\u60a3\u3002<\/p>\n

\u53d7\u5230\u540c\u6e90\u7b56\u7565\u7684\u5f71\u54cd\uff0c\u8de8\u57df\u8d44\u6e90\u5171\u4eab\u5c31\u4f1a\u53d7\u5230\u5236\u7ea6\u3002\u4f46\u662f\u968f\u7740\u4eba\u4eec\u7684\u5b9e\u8df5\u548c\u6d4f\u89c8\u5668\u7684\u8fdb\u6b65\uff0c\u76ee\u524d\u5728\u8de8\u57df\u8bf7\u6c42\u7684\u6280\u5de7\u4e0a\uff0c\u6709\u5f88\u591a\u5b9d\u8d35\u7ecf\u9a8c\u7684\u6c89\u6dc0\u548c\u79ef\u7d2f\u3002\u8fd9\u91cc\u6211\u628a\u8de8\u57df\u8d44\u6e90\u5171\u4eab\u5206\u6210\u4e24\u79cd\uff0c\u4e00\u79cd\u662f\u5355\u5411\u7684\u6570\u636e\u8bf7\u6c42\uff0c\u8fd8\u6709\u4e00\u79cd\u662f\u53cc\u5411\u7684\u6d88\u606f\u901a\u4fe1\u3002\u63a5\u4e0b\u6765\u6211\u5c06\u7f57\u5217\u51fa\u5e38\u89c1\u7684\u4e00\u4e9b\u8de8\u57df\u65b9\u5f0f\uff0c\u4ee5\u4e0b\u8de8\u57df\u5b9e\u4f8b\u7684\u6e90\u4ee3\u7801\u53ef\u4ee5\u4ece\u8fd9\u91cc\u83b7\u5f97<\/span><\/a><\/strong>\u3002<\/p>\n

\u5355\u5411\u8de8\u57df<\/h3>\n

JSONP<\/h4>\n

JSONP (JSON with Padding)\u662f\u4e00\u4e2a\u7b80\u5355\u9ad8\u6548\u7684\u8de8\u57df\u65b9\u5f0f\uff0cHTML\u4e2d\u7684script\u6807\u7b7e\u53ef\u4ee5\u52a0\u8f7d\u5e76\u6267\u884c\u5176\u4ed6\u57df\u7684JavaScript\uff0c\u4e8e\u662f\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7script\u6807\u8bb0\u6765\u52a8\u6001\u52a0\u8f7d\u5176\u4ed6\u57df\u7684\u8d44\u6e90\u3002\u4f8b\u5982\u6211\u8981\u4ece\u57dfA\u7684\u9875\u9762pageA\u52a0\u8f7d\u57dfB\u7684\u6570\u636e\uff0c\u90a3\u4e48\u5728\u57dfB\u7684\u9875\u9762pageB\u4e2d\u6211\u4ee5JavaScript\u7684\u5f62\u5f0f\u58f0\u660epageA\u9700\u8981\u7684\u6570\u636e\uff0c\u7136\u540e\u5728pageA\u4e2d\u7528script\u6807\u7b7e\u628apageB\u52a0\u8f7d\u8fdb\u6765\uff0c\u90a3\u4e48pageB\u4e2d\u7684\u811a\u672c\u5c31\u4f1a\u5f97\u4ee5\u6267\u884c\u3002JSONP\u5728\u6b64\u57fa\u7840\u4e0a\u52a0\u5165\u4e86\u56de\u8c03\u51fd\u6570\uff0cpageB\u52a0\u8f7d\u5b8c\u4e4b\u540e\u4f1a\u6267\u884cpageA\u4e2d\u5b9a\u4e49\u7684\u51fd\u6570\uff0c\u6240\u9700\u8981\u7684\u6570\u636e\u4f1a\u4ee5\u53c2\u6570\u7684\u5f62\u5f0f\u4f20\u9012\u7ed9\u8be5\u51fd\u6570\u3002JSONP\u6613\u4e8e\u5b9e\u73b0\uff0c\u4f46\u662f\u4e5f\u4f1a\u5b58\u5728\u4e00\u4e9b\u5b89\u5168\u9690\u60a3\uff0c\u5982\u679c\u7b2c\u4e09\u65b9\u7684\u811a\u672c\u968f\u610f\u5730\u6267\u884c\uff0c\u90a3\u4e48\u5b83\u5c31\u53ef\u4ee5\u7be1\u6539\u9875\u9762\u5185\u5bb9\uff0c\u622a\u83b7\u654f\u611f\u6570\u636e\u3002\u4f46\u662f\u5728\u53d7\u4fe1\u4efb\u7684\u53cc\u65b9\u4f20\u9012\u6570\u636e\uff0cJSONP\u662f\u975e\u5e38\u5408\u9002\u7684\u9009\u62e9\u3002<\/p>\n<\/p>\n

JSONP \u662f\u6784\u5efa mashup \u7684\u5f3a\u5927\u6280\u672f\uff0c\u4f46\u4e0d\u5e78\u7684\u662f\uff0c\u5b83\u5e76\u4e0d\u662f\u6240\u6709\u8de8\u57df\u901a\u4fe1\u9700\u6c42\u7684\u4e07\u7075\u836f\u3002\u5b83\u6709\u4e00\u4e9b\u7f3a\u9677\uff0c\u5728\u63d0\u4ea4\u5f00\u53d1\u8d44\u6e90\u4e4b\u524d\u5fc5\u987b\u8ba4\u771f\u8003\u8651\u5b83\u4eec\u3002\u7b2c\u4e00\uff0c\u4e5f\u662f\u6700\u91cd\u8981\u7684\u4e00\u70b9\uff0c\u6ca1\u6709\u5173\u4e8e JSONP \u8c03\u7528\u7684\u9519\u8bef\u5904\u7406\u3002\u5982\u679c\u52a8\u6001\u811a\u672c\u63d2\u5165\u6709\u6548\uff0c\u5c31\u6267\u884c\u8c03\u7528\uff1b\u5982\u679c\u65e0\u6548\uff0c\u5c31\u9759\u9ed8\u5931\u8d25\u3002\u5931\u8d25\u662f\u6ca1\u6709\u4efb\u4f55\u63d0\u793a\u7684\u3002\u4f8b\u5982\uff0c\u4e0d\u80fd\u4ece\u670d\u52a1\u5668\u6355\u6349\u5230 404 \u9519\u8bef\uff0c\u4e5f\u4e0d\u80fd\u53d6\u6d88\u6216\u91cd\u65b0\u5f00\u59cb\u8bf7\u6c42\u3002\u4e0d\u8fc7\uff0c\u7b49\u5f85\u4e00\u6bb5\u65f6\u95f4\u8fd8\u6ca1\u6709\u54cd\u5e94\u7684\u8bdd\uff0c\u5c31\u4e0d\u7528\u7406\u5b83\u4e86\u3002\uff08\u672a\u6765\u7684 jQuery \u7248\u672c\u53ef\u80fd\u6709\u7ec8\u6b62 JSONP \u8bf7\u6c42\u7684\u7279\u6027\uff09\u3002<\/p>\n

JSONP \u7684\u53e6\u4e00\u4e2a\u4e3b\u8981\u7f3a\u9677\u662f\u88ab\u4e0d\u4fe1\u4efb\u7684\u670d\u52a1\u4f7f\u7528\u65f6\u4f1a\u5f88\u5371\u9669\u3002\u56e0\u4e3a JSONP \u670d\u52a1\u8fd4\u56de\u6253\u5305\u5728\u51fd\u6570\u8c03\u7528\u4e2d\u7684 JSON \u54cd\u5e94\uff0c\u800c\u51fd\u6570\u8c03\u7528\u662f\u7531\u6d4f\u89c8\u5668\u6267\u884c\u7684\uff0c\u8fd9\u4f7f\u5bbf\u4e3b Web \u5e94\u7528\u7a0b\u5e8f\u66f4\u5bb9\u6613\u53d7\u5230\u5404\u7c7b\u653b\u51fb\u3002\u5982\u679c\u6253\u7b97\u4f7f\u7528 JSONP \u670d\u52a1\uff0c\u4e86\u89e3\u5b83\u80fd\u9020\u6210\u7684\u5a01\u80c1\u975e\u5e38\u91cd\u8981\u3002\uff08\u53c2\u89c1\u53c2\u8003\u8d44\u6599<\/a> \u4e86\u89e3\u66f4\u591a\u4fe1\u606f\uff09\u3002<\/p>\n<\/p>\n

Flash URLLoader<\/p>\n

Flash\u6709\u81ea\u5df1\u7684\u4e00\u5957\u5b89\u5168\u7b56\u7565\uff0c\u670d\u52a1\u5668\u53ef\u4ee5\u901a\u8fc7crossdomain.xml\u6587\u4ef6\u6765\u58f0\u660e\u80fd\u88ab\u54ea\u4e9b\u57df\u7684SWF\u6587\u4ef6\u8bbf\u95ee\uff0cSWF\u4e5f\u53ef\u4ee5\u901a\u8fc7API\u6765\u786e\u5b9a\u81ea\u8eab\u80fd\u88ab\u54ea\u4e9b\u57df\u7684SWF\u52a0\u8f7d\u3002\u5f53\u8de8\u57df\u8bbf\u95ee\u8d44\u6e90\u65f6\uff0c\u4f8b\u5982\u4ece\u57dfwww.a.com\u8bf7\u6c42\u57dfwww.b.com\u4e0a\u7684\u6570\u636e\uff0c\u6211\u4eec\u53ef\u4ee5\u501f\u52a9Flash\u6765\u53d1\u9001HTTP\u8bf7\u6c42\u3002\u9996\u5148\uff0c\u4fee\u6539\u57dfwww.b.com\u4e0a\u7684crossdomain.xml(\u4e00\u822c\u5b58\u653e\u5728\u6839\u76ee\u5f55\uff0c\u5982\u679c\u6ca1\u6709\u9700\u8981\u624b\u52a8\u521b\u5efa) \uff0c\u628awww.a.com\u52a0\u5165\u5230\u767d\u540d\u5355\u3002\u5176\u6b21\uff0c\u901a\u8fc7Flash URLLoader\u53d1\u9001HTTP\u8bf7\u6c42\uff0c\u6700\u540e\uff0c\u901a\u8fc7Flash API\u628a\u54cd\u5e94\u7ed3\u679c\u4f20\u9012\u7ed9JavaScript\u3002Flash URLLoader\u662f\u4e00\u79cd\u5f88\u666e\u904d\u7684\u8de8\u57df\u89e3\u51b3\u65b9\u6848\uff0c\u4e0d\u8fc7\u9700\u8981\u652f\u6301iOS\u7684\u8bdd\uff0c\u8fd9\u4e2a\u65b9\u6848\u5c31\u65e0\u80fd\u4e3a\u529b\u4e86\u3002<\/p>\n

Access Control<\/h4>\n

Access Control\u662f\u6bd4\u8f83\u8d85\u8d8a\u7684\u8de8\u57df\u65b9\u5f0f\uff0c\u76ee\u524d\u53ea\u5728\u5f88\u5c11\u7684\u6d4f\u89c8\u5668\u4e2d\u5f97\u4ee5\u652f\u6301\uff0c\u8fd9\u4e9b\u6d4f\u89c8\u5668\u53ef\u4ee5\u53d1\u9001\u4e00\u4e2a\u8de8\u57df\u7684HTTP\u8bf7\u6c42\uff08Firefox, Google Chrome\u7b49\u901a\u8fc7XMLHTTPRequest\u5b9e\u73b0\uff0cIE8\u4e0b\u901a\u8fc7XDomainRequest\u5b9e\u73b0\uff09\uff0c\u8bf7\u6c42\u7684\u54cd\u5e94\u5fc5\u987b\u5305\u542b\u4e00\u4e2aAccess-Control-Allow-Origin\u7684HTTP\u54cd\u5e94\u5934\uff0c\u8be5\u54cd\u5e94\u5934\u58f0\u660e\u4e86\u8bf7\u6c42\u57df\u7684\u53ef\u8bbf\u95ee\u6743\u9650\u3002\u4f8b\u5982www.a.com\u5bf9www.b.com\u4e0b\u7684asset.php\u53d1\u9001\u4e86\u4e00\u4e2a\u8de8\u57df\u7684HTTP\u8bf7\u6c42\uff0c\u90a3\u4e48asset.php\u5fc5\u987b\u52a0\u5165\u5982\u4e0b\u7684\u54cd\u5e94\u5934\uff1a<\/p>\n

header("Access-Control-Allow-Origin: http:\/\/www.a.com");<\/pre>\n<\/p>\n

window.name<\/h4>\n

window\u5bf9\u8c61\u7684name\u5c5e\u6027\u662f\u4e00\u4e2a\u5f88\u7279\u522b\u7684\u5c5e\u6027\uff0c\u5f53\u8be5window\u7684location\u53d8\u5316\uff0c\u7136\u540e\u91cd\u65b0\u52a0\u8f7d\uff0c\u5b83\u7684name\u5c5e\u6027\u53ef\u4ee5\u4f9d\u7136\u4fdd\u6301\u4e0d\u53d8\u3002\u90a3\u4e48\u6211\u4eec\u53ef\u4ee5\u5728\u9875\u9762A\u4e2d\u7528iframe\u52a0\u8f7d\u5176\u4ed6\u57df\u7684\u9875\u9762B\uff0c\u800c\u9875\u9762B\u4e2d\u7528JavaScript\u628a\u9700\u8981\u4f20\u9012\u7684\u6570\u636e\u8d4b\u503c\u7ed9window.name\uff0ciframe\u52a0\u8f7d\u5b8c\u6210\u4e4b\u540e\uff0c\u9875\u9762A\u4fee\u6539iframe\u7684\u5730\u5740\uff0c\u5c06\u5176\u53d8\u6210\u540c\u57df\u7684\u4e00\u4e2a\u5730\u5740\uff0c\u7136\u540e\u5c31\u53ef\u4ee5\u8bfb\u51fawindow.name\u7684\u503c\u4e86\u3002\u8fd9\u4e2a\u65b9\u5f0f\u975e\u5e38\u9002\u5408\u5355\u5411\u7684\u6570\u636e\u8bf7\u6c42\uff0c\u800c\u4e14\u534f\u8bae\u7b80\u5355\u3001\u5b89\u5168\u3002\u4e0d\u4f1a\u50cfJSONP\u90a3\u6837\u4e0d\u505a\u9650\u5236\u5730\u6267\u884c\u5916\u90e8\u811a\u672c\u3002<\/p>\n

server proxy<\/h4>\n

\u5728\u6570\u636e\u63d0\u4f9b\u65b9\u6ca1\u6709\u63d0\u4f9b\u5bf9JSONP\u534f\u8bae\u6216\u8005window.name\u534f\u8bae\u7684\u652f\u6301\uff0c\u4e5f\u6ca1\u6709\u5bf9\u5176\u5b83\u57df\u5f00\u653e\u8bbf\u95ee\u6743\u9650\u65f6\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7server proxy\u7684\u65b9\u5f0f\u6765\u6293\u53d6\u6570\u636e\u3002\u4f8b\u5982\u5f53www.a.com\u57df\u4e0b\u7684\u9875\u9762\u9700\u8981\u8bf7\u6c42www.b.com\u4e0b\u7684\u8d44\u6e90\u6587\u4ef6asset.txt\u65f6\uff0c\u76f4\u63a5\u53d1\u9001\u4e00\u4e2a\u6307\u5411www.b.com\/asset.txt\u7684ajax\u8bf7\u6c42\u80af\u5b9a\u662f\u4f1a\u88ab\u6d4f\u89c8\u5668\u963b\u6b62\u3002\u8fd9\u65f6\uff0c\u6211\u4eec\u5728www.a.com\u4e0b\u914d\u4e00\u4e2a\u4ee3\u7406\uff0c\u7136\u540e\u628aajax\u8bf7\u6c42\u7ed1\u5b9a\u5230\u8fd9\u4e2a\u4ee3\u7406\u8def\u5f84\u4e0b\uff0c\u4f8b\u5982www.a.com\/proxy\/, \u7136\u540e\u8fd9\u4e2a\u4ee3\u7406\u53d1\u9001HTTP\u8bf7\u6c42\u8bbf\u95eewww.b.com\u4e0b\u7684asset.txt\uff0c\u8de8\u57df\u7684HTTP\u8bf7\u6c42\u662f\u5728\u670d\u52a1\u5668\u7aef\u8fdb\u884c\u7684\uff0c\u5ba2\u6237\u7aef\u5e76\u6ca1\u6709\u4ea7\u751f\u8de8\u57df\u7684ajax\u8bf7\u6c42\u3002\u8fd9\u4e2a\u8de8\u57df\u65b9\u5f0f\u4e0d\u9700\u8981\u548c\u76ee\u6807\u8d44\u6e90\u7b7e\u8ba2\u534f\u8bae\uff0c\u5e26\u6709\u4fb5\u7565\u6027\uff0c\u53e6\u5916\u9700\u8981\u6ce8\u610f\u7684\u662f\u5b9e\u8df5\u4e2d\u5e94\u8be5\u5bf9\u8fd9\u4e2a\u4ee3\u7406\u5b9e\u65bd\u4e00\u5b9a\u7a0b\u5ea6\u7684\u4fdd\u62a4\uff0c\u6bd4\u5982\u9650\u5236\u4ed6\u4eba\u4f7f\u7528\u6216\u8005\u4f7f\u7528\u9891\u7387\u3002<\/p>\n

\u53cc\u5411\u8de8\u57df<\/h3>\n

document.domain<\/h4>\n

\u901a\u8fc7\u4fee\u6539document\u7684domain\u5c5e\u6027\uff0c\u6211\u4eec\u53ef\u4ee5\u5728\u57df\u548c\u5b50\u57df\u6216\u8005\u4e0d\u540c\u7684\u5b50\u57df\u4e4b\u95f4\u901a\u4fe1\u3002\u540c\u57df\u7b56\u7565\u8ba4\u4e3a\u57df\u548c\u5b50\u57df\u96b6\u5c5e\u4e8e\u4e0d\u540c\u7684\u57df\uff0c\u6bd4\u5982www.a.com\u548csub.a.com\u662f\u4e0d\u540c\u7684\u57df\uff0c\u8fd9\u65f6\uff0c\u6211\u4eec\u65e0\u6cd5\u5728www.a.com\u4e0b\u7684\u9875\u9762\u4e2d\u8c03\u7528sub.a.com\u4e2d\u5b9a\u4e49\u7684JavaScript\u65b9\u6cd5\u3002\u4f46\u662f\u5f53\u6211\u4eec\u628a\u5b83\u4eecdocument\u7684domain\u5c5e\u6027\u90fd\u4fee\u6539\u4e3aa.com\uff0c\u6d4f\u89c8\u5668\u5c31\u4f1a\u8ba4\u4e3a\u5b83\u4eec\u5904\u4e8e\u540c\u4e00\u4e2a\u57df\u4e0b\uff0c\u90a3\u4e48\u6211\u4eec\u5c31\u53ef\u4ee5\u4e92\u76f8\u8c03\u7528\u5bf9\u65b9\u7684method\u6765\u901a\u4fe1\u4e86\u3002<\/p>\n

FIM C Fragment Identitier Messaging<\/h4>\n

\u4e0d\u540c\u7684\u57df\u4e4b\u95f4\uff0cJavaScript\u53ea\u80fd\u505a\u5f88\u6709\u9650\u7684\u8bbf\u95ee\u548c\u64cd\u4f5c\uff0c\u5176\u5b9e\u6211\u4eec\u5229\u7528\u8fd9\u4e9b\u6709\u9650\u7684\u8bbf\u95ee\u6743\u9650\u5c31\u53ef\u4ee5\u8fbe\u5230\u8de8\u57df\u901a\u4fe1\u7684\u76ee\u7684\u4e86\u3002FIM (Fragment Identitier Messaging)\u5c31\u662f\u5728\u8fd9\u4e2a\u5927\u524d\u63d0\u4e0b\u88ab\u53d1\u660e\u7684\u3002\u7236\u7a97\u53e3\u53ef\u4ee5\u5bf9iframe\u8fdb\u884cURL\u8bfb\u5199\uff0ciframe\u4e5f\u53ef\u4ee5\u8bfb\u5199\u7236\u7a97\u53e3\u7684URL\uff0cURL\u6709\u4e00\u90e8\u5206\u88ab\u79f0\u4e3afrag\uff0c\u5c31\u662f#\u53f7\u53ca\u5176\u540e\u9762\u7684\u5b57\u7b26\uff0c\u5b83\u4e00\u822c\u7528\u4e8e\u6d4f\u89c8\u5668\u951a\u70b9\u5b9a\u4f4d\uff0cServer\u7aef\u5e76\u4e0d\u5173\u5fc3\u8fd9\u90e8\u5206\uff0c\u5e94\u8be5\u8bf4HTTP\u8bf7\u6c42\u8fc7\u7a0b\u4e2d\u4e0d\u4f1a\u643a\u5e26frag\uff0c\u6240\u4ee5\u8fd9\u90e8\u5206\u7684\u4fee\u6539\u4e0d\u4f1a\u4ea7\u751fHTTP\u8bf7\u6c42\uff0c\u4f46\u662f\u4f1a\u4ea7\u751f\u6d4f\u89c8\u5668\u5386\u53f2\u8bb0\u5f55\u3002FIM\u7684\u539f\u7406\u5c31\u662f\u6539\u53d8URL\u7684frag\u90e8\u5206\u6765\u8fdb\u884c\u53cc\u5411\u901a\u4fe1\u3002\u6bcf\u4e2awindow\u901a\u8fc7\u6539\u53d8\u5176\u4ed6window\u7684location\u6765\u53d1\u9001\u6d88\u606f\uff0c\u5e76\u901a\u8fc7\u76d1\u542c\u81ea\u5df1\u7684URL\u7684\u53d8\u5316\u6765\u63a5\u6536\u6d88\u606f\u3002\u8fd9\u4e2a\u65b9\u5f0f\u7684\u901a\u4fe1\u4f1a\u9020\u6210\u4e00\u4e9b\u4e0d\u5fc5\u8981\u7684\u6d4f\u89c8\u5668\u5386\u53f2\u8bb0\u5f55\uff0c\u800c\u4e14\u6709\u4e9b\u6d4f\u89c8\u5668\u4e0d\u652f\u6301onhashchange\u4e8b\u4ef6\uff0c\u9700\u8981\u8f6e\u8be2\u6765\u83b7\u77e5URL\u7684\u6539\u53d8\uff0c\u6700\u540e\uff0cURL\u5728\u6d4f\u89c8\u5668\u4e0b\u6709\u957f\u5ea6\u9650\u5236\uff0c\u8fd9\u4e2a\u5236\u7ea6\u4e86\u6bcf\u6b21\u4f20\u9001\u7684\u6570\u636e\u91cf\u3002<\/p>\n

Flash LocalConnection<\/h4>\n

\u9875\u9762\u4e0a\u7684\u53cc\u5411\u901a\u4fe1\u4e5f\u53ef\u4ee5\u901a\u8fc7Flash\u6765\u89e3\u51b3\uff0cFlash API\u4e2d\u6709LocalConnection\u8fd9\u4e2a\u7c7b\uff0c\u8be5\u7c7b\u5141\u8bb8\u4e24\u4e2aSWF\u4e4b\u95f4\u901a\u8fc7\u8fdb\u7a0b\u901a\u4fe1\uff0c\u8fd9\u65f6SWF\u53ef\u4ee5\u64ad\u653e\u5728\u72ec\u7acb\u7684Flash Player\u6216\u8005AIR\u4e2d\uff0c\u4e5f\u53ef\u4ee5\u5d4c\u5728HTML\u9875\u9762\u6216\u8005\u662fPDF\u4e2d\u3002\u9075\u5faa\u8fd9\u4e2a\u901a\u4fe1\u539f\u5219\uff0c\u6211\u4eec\u53ef\u4ee5\u5728\u4e0d\u540c\u57df\u7684HTML\u9875\u9762\u5404\u81ea\u5d4c\u5957\u4e00\u4e2aSWF\u6765\u8fbe\u5230\u76f8\u4e92\u4f20\u9012\u6570\u636e\u7684\u76ee\u7684\u4e86\u3002SWF\u901a\u8fc7LocalConnection\u4ea4\u6362\u6570\u636e\u662f\u5f88\u5feb\u7684\uff0c\u4f46\u662f\u6bcf\u6b21\u7684\u6570\u636e\u91cf\u670940kb\u7684\u5927\u5c0f\u9650\u5236\u3002\u7528\u8fd9\u79cd\u65b9\u5f0f\u6765\u8de8\u57df\u901a\u4fe1\u8fc7\u4e8e\u590d\u6742\uff0c\u800c\u4e14\u9700\u8981\u4e862\u4e2aSWF\u6587\u4ef6\uff0c\u5b9e\u7528\u6027\u4e0d\u5f3a\u3002<\/p>\n

window.postMessage<\/h4>\n

window.postMessage\u662fHTML5\u5b9a\u4e49\u7684\u4e00\u4e2a\u5f88\u65b0\u7684\u65b9\u6cd5<\/a>\uff0c\u8fd9\u4e2a\u65b9\u6cd5\u53ef\u4ee5\u5f88\u65b9\u4fbf\u5730\u8de8window\u901a\u4fe1\u3002\u7531\u4e8e\u5b83\u662f\u4e00\u4e2a\u5f88\u65b0\u7684\u65b9\u6cd5\uff0c\u6240\u4ee5\u5728\u5f88\u65e7\u548c\u6bd4\u8f83\u65e7\u7684\u6d4f\u89c8\u5668\u4e2d\u90fd\u65e0\u6cd5\u4f7f\u7528\u3002<\/p>\n

Cross Frame<\/h4>\n

Cross Frame\u662fFIM\u7684\u4e00\u4e2a\u53d8\u79cd\uff0c\u5b83\u501f\u52a9\u4e86\u4e00\u4e2a\u7a7a\u767d\u7684iframe\uff0c\u4e0d\u4f1a\u4ea7\u751f\u591a\u4f59\u7684\u6d4f\u89c8\u5668\u5386\u53f2\u8bb0\u5f55\uff0c\u4e5f\u4e0d\u9700\u8981\u8f6e\u8be2URL\u7684\u6539\u53d8\uff0c\u5728\u53ef\u7528\u6027\u548c\u6027\u80fd\u4e0a\u90fd\u505a\u4e86\u5f88\u5927\u7684\u6539\u89c2\u3002\u5b83\u7684\u57fa\u672c\u539f\u7406\u5927\u81f4\u662f\u8fd9\u6837\u7684\uff0c\u5047\u8bbe\u5728\u57dfwww.a.com\u4e0a\u6709\u9875\u9762A.html\u548c\u4e00\u4e2a\u7a7a\u767d\u4ee3\u7406\u9875\u9762proxyA.html, \u53e6\u4e00\u4e2a\u57dfwww.b.com\u4e0a\u6709\u4e2a\u9875\u9762B.html\u548c\u4e00\u4e2a\u7a7a\u767d\u4ee3\u7406\u9875\u9762proxyB.html\uff0cA.html\u9700\u8981\u5411B.html\u4e2d\u53d1\u9001\u6d88\u606f\u65f6\uff0c\u9875\u9762\u4f1a\u521b\u5efa\u4e00\u4e2a\u9690\u85cf\u7684iframe, iframe\u7684src\u6307\u5411proxyB.html\u5e76\u628amessage\u4f5c\u4e3aURL frag\uff0c\u7531\u4e8eB.html\u548cproxyB.html\u662f\u540c\u57df\uff0c\u6240\u4ee5\u5728iframe\u52a0\u8f7d\u5b8c\u6210\u4e4b\u540e\uff0cB.html\u53ef\u4ee5\u83b7\u5f97iframe\u7684URL\uff0c\u7136\u540e\u89e3\u6790\u51famessage\uff0c\u5e76\u79fb\u9664\u8be5iframe\u3002\u5f53B.html\u9700\u8981\u5411A.html\u53d1\u9001\u6d88\u606f\u65f6\uff0c\u539f\u7406\u4e00\u6837\u3002Cross Frame\u662f\u5f88\u597d\u7684\u53cc\u5411\u901a\u4fe1\u65b9\u5f0f\uff0c\u800c\u4e14\u5b89\u5168\u9ad8\u6548\uff0c\u4f46\u662f\u5b83\u5728Opera\u4e2d\u65e0\u6cd5\u4f7f\u7528\uff0c\u4e0d\u8fc7\u5728Opera\u4e0b\u9762\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u66f4\u7b80\u5355\u7684window.postMessage\u6765\u4ee3\u66ff\u3002<\/p>\n

\u603b\u7ed3<\/h3>\n

\u8de8\u57df\u7684\u65b9\u6cd5\u5f88\u591a\uff0c\u4e0d\u540c\u7684\u5e94\u7528\u573a\u666f\u6211\u4eec\u90fd\u53ef\u4ee5\u627e\u5230\u4e00\u4e2a\u6700\u5408\u9002\u7684\u89e3\u51b3\u65b9\u6848\u3002\u6bd4\u5982\u5355\u5411\u7684\u6570\u636e\u8bf7\u6c42\uff0c\u6211\u4eec\u5e94\u8be5\u4f18\u5148\u9009\u62e9JSONP\u6216\u8005window.name\uff0c\u53cc\u5411\u901a\u4fe1\u6211\u4eec\u91c7\u53d6Cross Frame\uff0c\u5728\u672a\u4e0e\u6570\u636e\u63d0\u4f9b\u65b9\u6ca1\u6709\u8fbe\u6210\u901a\u4fe1\u534f\u8bae\u7684\u60c5\u51b5\u4e0b\u6211\u4eec\u4e5f\u53ef\u4ee5\u7528server proxy\u7684\u65b9\u5f0f\u6765\u6293\u53d6\u6570\u636e\u3002<\/p><\/p>\n","protected":false},"excerpt":{"rendered":"

\u8de8\u57df\u95ee\u9898\u7b97\u662f\u8001\u751f\u957f\u8c08\u7684\u4e86\uff0c\u4e0b\u9762\u662f\u53e3\u7891UDE\u56e2\u961f\u6574\u7406\u7684\u8d44\u6599\uff0c\u6709\u4ee3\u7801\u6f14\u793a\u53ef\u4f9b\u4e0b\u8f7d \u3002<\/p>\n<\/p>\n

\u540c\u6e90\u7b56\u7565<\/span><\/h3>\n<\/p>\n

\u5728\u5ba2\u6237\u7aef\u7f16\u7a0b\u8bed\u8a00\u4e2d\uff0c\u5982JavaScript\u548cActionScript\uff0c\u540c\u6e90\u7b56\u7565\u662f\u4e00\u4e2a\u5f88\u91cd\u8981\u7684\u5b89\u5168\u7406\u5ff5\uff0c\u5b83\u5728\u4fdd\u8bc1\u6570\u636e\u7684\u5b89\u5168\u6027\u65b9\u9762\u6709\u7740\u91cd\u8981\u7684\u610f\u4e49\u3002\u540c\u6e90\u7b56\u7565\u89c4\u5b9a\u8de8\u57df\u4e4b\u95f4\u7684\u811a\u672c\u662f\u9694\u79bb\u7684\uff0c\u4e00\u4e2a\u57df\u7684\u811a\u672c\u4e0d\u80fd\u8bbf\u95ee\u548c\u64cd\u4f5c\u53e6\u5916\u4e00\u4e2a\u57df\u7684\u7edd\u5927\u90e8\u5206\u5c5e\u6027\u548c\u65b9\u6cd5\u3002\u90a3\u4e48\u4ec0\u4e48\u53eb\u76f8\u540c\u57df\uff0c\u4ec0\u4e48\u53eb\u4e0d\u540c\u7684\u57df\u5462\uff1f\u5f53\u4e24\u4e2a\u57df\u5177\u6709\u76f8\u540c\u7684\u534f\u8bae(\u5982http), \u76f8\u540c\u7684\u7aef\u53e3(\u598280)\uff0c\u76f8\u540c\u7684host\uff08\u5982w<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/blog.vimge.com\/wp-json\/wp\/v2\/posts\/1138"}],"collection":[{"href":"https:\/\/blog.vimge.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.vimge.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.vimge.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.vimge.com\/wp-json\/wp\/v2\/comments?post=1138"}],"version-history":[{"count":1,"href":"https:\/\/blog.vimge.com\/wp-json\/wp\/v2\/posts\/1138\/revisions"}],"predecessor-version":[{"id":1296,"href":"https:\/\/blog.vimge.com\/wp-json\/wp\/v2\/posts\/1138\/revisions\/1296"}],"wp:attachment":[{"href":"https:\/\/blog.vimge.com\/wp-json\/wp\/v2\/media?parent=1138"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.vimge.com\/wp-json\/wp\/v2\/categories?post=1138"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.vimge.com\/wp-json\/wp\/v2\/tags?post=1138"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}