{"id":819,"date":"2012-03-17T00:13:53","date_gmt":"2012-03-16T16:13:53","guid":{"rendered":""},"modified":"2014-03-11T22:41:34","modified_gmt":"2014-03-11T14:41:34","slug":"js%e5%ae%9e%e7%8e%b0%e5%9b%be%e7%89%87%e9%a2%84%e5%8a%a0%e8%bd%bd","status":"publish","type":"post","link":"http:\/\/www.xiaoyebailong.com\/index.php\/2012\/03\/17\/819.htm","title":{"rendered":"JS\u5b9e\u73b0\u56fe\u7247\u9884\u52a0\u8f7d"},"content":{"rendered":"<div class=\"postBody\">\u7f51\u7ad9\u5f00\u53d1\u65f6\u7ecf\u5e38\u9700\u8981\u5728\u67d0\u4e2a\u9875\u9762\u9700\u8981\u5b9e\u73b0\u5bf9\u5927\u91cf\u56fe\u7247\u7684\u6d4f\u89c8\uff0c\u5982\u679c\u8003\u8651\u6d41\u91cf\u7684\u8bdd\uff0c\u5927\u53ef\u4ee5\u50cfpconline\u4e00\u6837\u6bcf\u4e2a\u9875\u9762\u53ea\u663e\u793a\u4e00\u5f20\u56fe\u7247\uff0c\u8ba9\u7528\u6237\u6bcf\u770b\u4e00\u5f20\u56fe\u7247\u5c31\u9700\u8981\u91cd\u65b0\u4e0b\u8f7d\u4e00\u4e0b\u6574\u4e2a\u9875\u9762\u3002\u4e0d\u8fc7\uff0c\u5728web2.0\u65f6\u4ee3\uff0c\u66f4\u591a\u4eba\u613f\u610f\u7528javascript\u6765\u5b9e\u73b0\u4e00\u4e2a\u56fe\u7247\u6d4f\u89c8\u5668\uff0c\u8ba9\u7528\u6237\u65e0\u9700\u7b49\u5f85\u8fc7\u957f\u7684\u65f6\u95f4\u5c31\u80fd\u770b\u5230\u5176\u4ed6\u56fe\u7247\u3002<\/p>\n<p>\u77e5\u9053\u4e86\u4e00\u5f20\u56fe\u7247\u7684\u5730\u5740\uff0c\u9700\u8981\u628a\u5b83\u5728\u4e00\u4e2a\u56fa\u5b9a\u5927\u5c0f\u7684html\u5bb9\u5668\uff08\u53ef\u4ee5\u662fdiv\u7b49\uff09\u91cc\u8fb9\u663e\u793a\u51fa\u6765\uff0c\u6700\u91cd\u8981\u7684\u5f53\u7136\u662f\u9700\u8981\u77e5\u9053\u8fd9\u5f20\u5373\u5c06\u663e\u793a\u7684\u56fe\u7247\u7684\u5bbd\u548c\u9ad8\uff0c\u7136\u540e\u518d\u7ed3\u5408\u5bb9\u5668\u7684\u5bbd\u548c\u9ad8\uff0c\u6309\u7167\u4e00\u5b9a\u7684\u7f29\u653e\u6bd4\u4f8b\u4f7f\u56fe\u7247\u663e\u793a\u51fa\u6765\u3002\u56e0\u6b64\uff0c\u5b9e\u73b0\u56fe\u7247\u9884\u52a0\u8f7d\u5c31\u6210\u4e3a\u56fe\u7247\u6d4f\u89c8\u5668\u7684\u6838\u5fc3\u529f\u80fd\u4e86\u3002<\/p>\n<p>\u505a\u8fc7\u56fe\u7247\u7ffb\u8f6c\u6548\u679c\u7684\u670b\u53cb\u5176\u5b9e\u90fd\u77e5\u9053\uff0c\u8981\u8ba9\u56fe\u7247\u8f6e\u6362\u7684\u65f6\u5019\u4e0d\u51fa\u73b0\u7b49\u5f85\uff0c\u6700\u597d\u662f\u5148\u8ba9\u56fe\u7247\u4e0b\u8f7d\u5230\u672c\u5730\uff0c\u8ba9\u6d4f\u89c8\u5668\u7f13\u5b58\u8d77\u6765\u3002\u8fd9\u65f6\uff0c\u4e00\u822c\u90fd\u4f1a\u7528\u5230js\u91cc\u8fb9\u7684Image\u5bf9\u8c61\u3002\u4e00\u822c\u7684\u624b\u6bb5\u65e0\u975e\u8fd9\u6837\uff1a<\/p>\n<div style=\"border-bottom: rgb(204,204,204) 1px solid; border-left: rgb(204,204,204) 1px solid; padding-bottom: 4px; background-color: rgb(238,238,238); padding-left: 4px; width: 98%; padding-right: 5px; font-size: 13px; border-top: rgb(204,204,204) 1px solid; border-right: rgb(204,204,204) 1px solid; padding-top: 4px\"><img decoding=\"async\" alt=\"\" align=\"top\" src=\"http:\/\/www.cnblogs.com\/Images\/OutliningIndicators\/ExpandedBlockStart.gif\" \/><img decoding=\"async\" alt=\"\" align=\"top\" style=\"display: none\" src=\"http:\/\/www.cnblogs.com\/Images\/OutliningIndicators\/ContractedBlock.gif\" \/><span style=\"color: rgb(0,0,255)\">function<\/span><span style=\"color: rgb(0,0,0)\"> preLoadImg(url) <\/span><span style=\"border-bottom: rgb(128,128,128) 1px solid; border-left: rgb(128,128,128) 1px solid; background-color: rgb(255,255,255); display: none; border-top: rgb(128,128,128) 1px solid; border-right: rgb(128,128,128) 1px solid\"><img decoding=\"async\" alt=\"\" src=\"http:\/\/www.cnblogs.com\/Images\/dot.gif\" \/><\/span><span><span style=\"color: rgb(0,0,0)\">{<br \/>\n<img decoding=\"async\" alt=\"\" align=\"top\" src=\"http:\/\/www.cnblogs.com\/Images\/OutliningIndicators\/InBlock.gif\" \/><\/span><span style=\"color: rgb(0,0,255)\"> var<\/span><span style=\"color: rgb(0,0,0)\"> img <\/span><span style=\"color: rgb(0,0,0)\">=<\/span><span style=\"color: rgb(0,0,0)\"> <\/span><span style=\"color: rgb(0,0,255)\">new<\/span><span style=\"color: rgb(0,0,0)\"> Image();<br \/>\n<img decoding=\"async\" alt=\"\" align=\"top\" src=\"http:\/\/www.cnblogs.com\/Images\/OutliningIndicators\/InBlock.gif\" \/> img.src <\/span><span style=\"color: rgb(0,0,0)\">=<\/span><span style=\"color: rgb(0,0,0)\"> url;<br \/>\n<img decoding=\"async\" alt=\"\" align=\"top\" src=\"http:\/\/www.cnblogs.com\/Images\/OutliningIndicators\/ExpandedBlockEnd.gif\" \/>}<\/span><\/span><\/div>\n<p>\n\u901a\u8fc7\u8c03\u7528preLoadImg\u51fd\u6570\uff0c\u4f20\u5165\u56fe\u7247\u7684url\uff0c\u5c31\u80fd\u4f7f\u56fe\u7247\u9884\u5148\u4e0b\u8f7d\u4e0b\u6765\u4e86\u3002\u5b9e\u9645\u4e0a\uff0c\u8fd9\u91cc\u7528\u5230\u7684\u9884\u4e0b\u8f7d\u529f\u80fd\u4e5f\u548c\u8fd9\u57fa\u672c\u4e00\u81f4\u3002\u56fe\u7247\u9884\u4e0b\u8f7d\u4e0b\u6765\u540e\uff0c\u901a\u8fc7 img\u7684width\u548cheight\u5c5e\u6027\uff0c\u5c31\u80fd\u77e5\u9053\u56fe\u7247\u7684\u5bbd\u548c\u9ad8\u4e86\u3002\u4f46\u662f\u9700\u8981\u8003\u8651\u5230\uff0c\u5728\u505a\u56fe\u7247\u6d4f\u89c8\u5668\u529f\u80fd\u65f6\uff0c\u56fe\u7247\u90fd\u662f\u5b9e\u65f6\u663e\u793a\u7684\u3002\u6bd4\u5982\u4f60\u70b9\u4e86\u663e\u793a\u7684\u6309\u94ae\uff0c\u8fd9\u4e2a\u65f6\u5019\u624d\u4f1a\u8c03\u7528\u4e0a\u8fb9\u7c7b\u4f3c\u7684\u4ee3\u7801\u6765\u52a0\u8f7d\u56fe\u7247\u3002\u56e0\u6b64\uff0c\u5982\u679c\u4f60\u76f4\u63a5\u7528img.width\u7684\u65f6\u5019\uff0c\u56fe\u7247\u8fd8\u6ca1\u6709\u5b8c\u5168\u4e0b\u8f7d\u4e0b\u6765\u3002\u56e0\u6b64\uff0c\u9700\u8981\u7528\u4e00\u4e9b\u5f02\u6b65\u7684\u65b9\u6cd5\uff0c\u7b49\u5230\u56fe\u7247\u4e0b\u8f7d\u5b8c\u6bd5\u7684\u65f6\u5019\u624d\u4f1a\u518d\u5bf9img\u7684width\u548cheight\u8fdb\u884c\u8c03\u7528\u3002<\/p>\n<p>\u5b9e\u73b0\u8fd9\u6837\u7684\u5f02\u6b65\u65b9\u6cd5\u5b9e\u9645\u4e0a\u4e0d\u96be\uff0c\u56fe\u7247\u7684\u4e0b\u8f7d\u5b8c\u6bd5\u4e8b\u4ef6\u4e5f\u5f88\u7b80\u5355\uff0c\u5c31\u662f\u7b80\u5355\u7684onload\u4e8b\u4ef6\u3002\u56e0\u6b64\uff0c\u6211\u4eec\u53ef\u4ee5\u5199\u51fa\u4e0b\u9762\u7684\u4ee3\u7801\uff1a<\/p>\n<div style=\"border-bottom: rgb(204,204,204) 1px solid; border-left: rgb(204,204,204) 1px solid; padding-bottom: 4px; background-color: rgb(238,238,238); padding-left: 4px; width: 98%; padding-right: 5px; font-size: 13px; border-top: rgb(204,204,204) 1px solid; border-right: rgb(204,204,204) 1px solid; padding-top: 4px\"><img decoding=\"async\" alt=\"\" align=\"top\" src=\"http:\/\/www.cnblogs.com\/Images\/OutliningIndicators\/ExpandedBlockStart.gif\" \/><img decoding=\"async\" alt=\"\" align=\"top\" style=\"display: none\" src=\"http:\/\/www.cnblogs.com\/Images\/OutliningIndicators\/ContractedBlock.gif\" \/><span style=\"color: rgb(0,0,255)\">function<\/span><span style=\"color: rgb(0,0,0)\"> loadImage(url, callback) <\/span><span style=\"border-bottom: rgb(128,128,128) 1px solid; border-left: rgb(128,128,128) 1px solid; background-color: rgb(255,255,255); display: none; border-top: rgb(128,128,128) 1px solid; border-right: rgb(128,128,128) 1px solid\"><img decoding=\"async\" alt=\"\" src=\"http:\/\/www.cnblogs.com\/Images\/dot.gif\" \/><\/span><span><span style=\"color: rgb(0,0,0)\">{<br \/>\n<img decoding=\"async\" alt=\"\" align=\"top\" src=\"http:\/\/www.cnblogs.com\/Images\/OutliningIndicators\/InBlock.gif\" \/>&nbsp;&nbsp;<\/span><span style=\"color: rgb(0,0,255)\">var<\/span><span style=\"color: rgb(0,0,0)\"> img <\/span><span style=\"color: rgb(0,0,0)\">=<\/span><span style=\"color: rgb(0,0,0)\"> <\/span><span style=\"color: rgb(0,0,255)\">new<\/span><span style=\"color: rgb(0,0,0)\"> Image();<br \/>\n<img decoding=\"async\" alt=\"\" align=\"top\" src=\"http:\/\/www.cnblogs.com\/Images\/OutliningIndicators\/InBlock.gif\" \/>&nbsp;&nbsp; img.src <\/span><span style=\"color: rgb(0,0,0)\">=<\/span><span style=\"color: rgb(0,0,0)\"> url;<br \/>\n<img decoding=\"async\" alt=\"\" align=\"top\" src=\"http:\/\/www.cnblogs.com\/Images\/OutliningIndicators\/InBlock.gif\" \/><br \/>\n<img decoding=\"async\" alt=\"\" align=\"top\" src=\"http:\/\/www.cnblogs.com\/Images\/OutliningIndicators\/ExpandedSubBlockStart.gif\" \/><img decoding=\"async\" alt=\"\" align=\"top\" style=\"display: none\" src=\"http:\/\/www.cnblogs.com\/Images\/OutliningIndicators\/ContractedSubBlock.gif\" \/>&nbsp;&nbsp; img.onload <\/span><span style=\"color: rgb(0,0,0)\">=<\/span><span style=\"color: rgb(0,0,0)\"> <\/span><span style=\"color: rgb(0,0,255)\">function<\/span><span style=\"color: rgb(0,0,0)\">()<\/span><span style=\"border-bottom: rgb(128,128,128) 1px solid; border-left: rgb(128,128,128) 1px solid; background-color: rgb(255,255,255); display: none; border-top: rgb(128,128,128) 1px solid; border-right: rgb(128,128,128) 1px solid\"><img decoding=\"async\" alt=\"\" src=\"http:\/\/www.cnblogs.com\/Images\/dot.gif\" \/><\/span><span><span style=\"color: rgb(0,0,0)\">{ <\/span><span style=\"color: rgb(0,128,0)\">\/\/<\/span><span style=\"color: rgb(0,128,0)\">\u56fe\u7247\u4e0b\u8f7d\u5b8c\u6bd5\u65f6\u5f02\u6b65\u8c03\u7528callback\u51fd\u6570\u3002<\/span><span style=\"color: rgb(0,128,0)\"><br \/>\n<img decoding=\"async\" alt=\"\" align=\"top\" src=\"http:\/\/www.cnblogs.com\/Images\/OutliningIndicators\/InBlock.gif\" \/><\/span><span style=\"color: rgb(0,0,0)\">&nbsp;&nbsp;&nbsp;&nbsp; callback.call(img);&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: rgb(0,128,0)\">\/\/<\/span><span style=\"color: rgb(0,128,0)\"> \u5c06callback\u51fd\u6570this\u6307\u9488\u5207\u6362\u4e3aimg\u3002<\/span><span style=\"color: rgb(0,128,0)\"><br \/>\n<img decoding=\"async\" alt=\"\" align=\"top\" src=\"http:\/\/www.cnblogs.com\/Images\/OutliningIndicators\/ExpandedSubBlockEnd.gif\" \/><\/span><span style=\"color: rgb(0,0,0)\">&nbsp;&nbsp; }<\/span><\/span><span style=\"color: rgb(0,0,0)\">;<br \/>\n<img decoding=\"async\" alt=\"\" align=\"top\" src=\"http:\/\/www.cnblogs.com\/Images\/OutliningIndicators\/ExpandedBlockEnd.gif\" \/>}<\/span><\/span><\/div>\n<p>\u597d\u4e86\uff0c\u518d\u6765\u5199\u4e00\u4e2a\u6d4b\u8bd5\u7528\u4f8b\u3002<\/p>\n<div style=\"border-bottom: rgb(204,204,204) 1px solid; border-left: rgb(204,204,204) 1px solid; padding-bottom: 4px; background-color: rgb(238,238,238); padding-left: 4px; width: 98%; padding-right: 5px; font-size: 13px; border-top: rgb(204,204,204) 1px solid; border-right: rgb(204,204,204) 1px solid; padding-top: 4px\"><img decoding=\"async\" alt=\"\" align=\"top\" src=\"http:\/\/www.cnblogs.com\/Images\/OutliningIndicators\/None.gif\" \/><span style=\"color: rgb(0,0,0)\">function imgLoaded(){<br \/>\n<img decoding=\"async\" alt=\"\" align=\"top\" src=\"http:\/\/www.cnblogs.com\/Images\/OutliningIndicators\/None.gif\" \/>&nbsp;&nbsp; alert(this.width);<br \/>\n<img decoding=\"async\" alt=\"\" align=\"top\" src=\"http:\/\/www.cnblogs.com\/Images\/OutliningIndicators\/None.gif\" \/>}<br \/>\n<img decoding=\"async\" alt=\"\" align=\"top\" src=\"http:\/\/www.cnblogs.com\/Images\/OutliningIndicators\/None.gif\" \/><\/span><span style=\"color: rgb(0,0,255)\">&lt;<\/span><span style=\"color: rgb(128,0,0)\">input <\/span><span style=\"color: rgb(255,0,0)\">type<\/span><span style=\"color: rgb(0,0,255)\">=&quot;button&quot;<\/span><span style=\"color: rgb(255,0,0)\"> value<\/span><span style=\"color: rgb(0,0,255)\">=&quot;loadImage&quot;<\/span><span style=\"color: rgb(255,0,0)\"> onclick<\/span><span style=\"color: rgb(0,0,255)\">=&quot;loadImage(&#8216;aaa.jpg&#8217;,imgLoaded)&quot;<\/span><span style=\"color: rgb(0,0,255)\">\/&gt;<\/span><span style=\"color: rgb(0,0,0)\"><br \/>\n<img decoding=\"async\" alt=\"\" align=\"top\" src=\"http:\/\/www.cnblogs.com\/Images\/OutliningIndicators\/None.gif\" \/><\/span><\/div>\n<p>\n\u5728firefox\u4e2d\u6d4b\u8bd5\u4e00\u4e0b\uff0c\u53d1\u73b0\u4e0d\u9519\uff0c\u679c\u7136\u548c\u9884\u60f3\u7684\u6548\u679c\u4e00\u6837\uff0c\u5728\u56fe\u7247\u4e0b\u8f7d\u540e\uff0c\u5c31\u4f1a\u5f39\u51fa\u56fe\u7247\u7684\u5bbd\u5ea6\u6765\u3002\u65e0\u8bba\u70b9\u51fb\u591a\u5c11\u6b21\u6216\u8005\u5237\u65b0\u7ed3\u679c\u90fd\u4e00\u6837\u3002<\/p>\n<p>\u4e0d\u8fc7\uff0c\u505a\u5230\u8fd9\u4e00\u6b65\uff0c\u5148\u522b\u9ad8\u5174\u592a\u65e9&mdash;&mdash;\u8fd8\u9700\u8981\u8003\u8651\u4e00\u4e0b\u6d4f\u89c8\u5668\u7684\u517c\u5bb9\u6027\uff0c\u4e8e\u662f\uff0c\u8d76\u7d27\u5230ie\u91cc\u8fb9\u6d4b\u8bd5\u4e00\u4e0b\u3002\u6ca1\u9519\uff0c\u540c\u6837\u5f39\u51fa\u4e86\u56fe\u7247\u7684\u5bbd\u5ea6\u3002\u4f46\u662f\uff0c\u518d\u70b9\u51fbload\u7684\u65f6\u5019\uff0c\u60c5\u51b5\u5c31\u4e0d\u4e00\u6837\u4e86\uff0c\u4ec0\u4e48\u53cd\u5e94\u90fd\u6ca1\u6709\u4e86\u3002\u5237\u65b0\u4e00\u4e0b\uff0c\u4e5f\u540c\u6837\u5982\u6b64\u3002<\/p>\n<p>\u7ecf\u8fc7\u5bf9\u591a\u4e2a\u6d4f\u89c8\u5668\u7248\u672c\u7684\u6d4b\u8bd5\uff0c\u53d1\u73b0ie6\u3001opera\u90fd\u4f1a\u8fd9\u6837\uff0c\u800cfirefox\u548csafari\u5219\u8868\u73b0\u6b63\u5e38\u3002\u5176\u5b9e\uff0c\u539f\u56e0\u4e5f\u633a\u7b80\u5355\u7684\uff0c\u5c31\u662f\u56e0\u4e3a\u6d4f\u89c8\u5668\u7684\u7f13\u5b58\u4e86\u3002\u5f53\u56fe\u7247\u52a0\u8f7d\u8fc7\u4e00\u6b21\u4ee5\u540e\uff0c\u5982\u679c\u518d\u6709\u5bf9\u8be5\u56fe\u7247\u7684\u8bf7\u6c42\u65f6\uff0c\u7531\u4e8e\u6d4f\u89c8\u5668\u5df2\u7ecf\u7f13\u5b58\u4f4f\u8fd9\u5f20\u56fe\u7247\u4e86\uff0c\u4e0d\u4f1a\u518d\u53d1\u8d77\u4e00\u6b21\u65b0\u7684\u8bf7\u6c42\uff0c\u800c\u662f\u76f4\u63a5\u4ece\u7f13\u5b58\u4e2d\u52a0\u8f7d\u8fc7\u6765\u3002\u5bf9\u4e8e firefox\u548csafari\uff0c\u5b83\u4eec\u89c6\u56fe\u4f7f\u8fd9\u4e24\u79cd\u52a0\u8f7d\u65b9\u5f0f\u5bf9\u7528\u6237\u900f\u660e\uff0c\u540c\u6837\u4f1a\u5f15\u8d77\u56fe\u7247\u7684onload\u4e8b\u4ef6\uff0c\u800cie\u548copera\u5219\u5ffd\u7565\u4e86\u8fd9\u79cd\u540c\u4e00\u6027\uff0c\u4e0d\u4f1a\u5f15\u8d77\u56fe\u7247\u7684onload\u4e8b\u4ef6\uff0c\u56e0\u6b64\u4e0a\u8fb9\u7684\u4ee3\u7801\u5728\u5b83\u4eec\u91cc\u8fb9\u4e0d\u80fd\u5f97\u4ee5\u5b9e\u73b0\u6548\u679c\u3002<\/p>\n<p>\u600e\u4e48\u529e\u5462\uff1f\u6700\u597d\u7684\u60c5\u51b5\u662fImage\u53ef\u4ee5\u6709\u4e00\u4e2a\u72b6\u6001\u503c\u8868\u660e\u5b83\u662f\u5426\u5df2\u7ecf\u8f7d\u5165\u6210\u529f\u4e86\u3002\u4ece\u7f13\u5b58\u52a0\u8f7d\u7684\u65f6\u5019\uff0c\u56e0\u4e3a\u4e0d\u9700\u8981\u7b49\u5f85\uff0c\u8fd9\u4e2a\u72b6\u6001\u503c\u5c31\u76f4\u63a5\u662f\u8868\u660e\u5df2\u7ecf\u4e0b\u8f7d\u4e86\uff0c\u800c\u4ecehttp\u8bf7\u6c42\u52a0\u8f7d\u65f6\uff0c\u56e0\u4e3a\u9700\u8981\u7b49\u5f85\u4e0b\u8f7d\uff0c\u8fd9\u4e2a\u503c\u663e\u793a\u4e3a\u672a\u5b8c\u6210\u3002\u8fd9\u6837\u7684\u8bdd\uff0c\u5c31\u53ef\u4ee5\u641e\u5b9a\u4e86\u3002<\/p>\n<p>\u7ecf\u8fc7\u4e00\u4e9b\u5206\u6790\uff0c\u7ec8\u4e8e\u53d1\u73b0\u4e00\u4e2a\u4e3a\u5404\u4e2a\u6d4f\u89c8\u5668\u6240\u517c\u5bb9\u7684Image\u7684\u5c5e\u6027&mdash;&mdash;complete\u3002\u6240\u4ee5\uff0c\u5728\u56fe\u7247onload\u4e8b\u4ef6\u4e4b\u524d\u5148\u5bf9\u8fd9\u4e2a\u503c\u505a\u4e00\u4e0b\u5224\u65ad\u5373\u53ef\u3002\u6700\u540e\uff0c\u4ee3\u7801\u53d8\u6210\u5982\u4e0b\u7684\u6837\u5b50\uff1a<\/p>\n<div style=\"border-bottom: rgb(204,204,204) 1px solid; border-left: rgb(204,204,204) 1px solid; padding-bottom: 4px; background-color: rgb(238,238,238); padding-left: 4px; width: 98%; padding-right: 5px; font-size: 13px; border-top: rgb(204,204,204) 1px solid; border-right: rgb(204,204,204) 1px solid; padding-top: 4px\"><img decoding=\"async\" alt=\"\" align=\"top\" src=\"http:\/\/www.cnblogs.com\/Images\/OutliningIndicators\/ExpandedBlockStart.gif\" \/><img decoding=\"async\" alt=\"\" align=\"top\" style=\"display: none\" src=\"http:\/\/www.cnblogs.com\/Images\/OutliningIndicators\/ContractedBlock.gif\" \/><span style=\"color: rgb(0,0,255)\">function<\/span><span style=\"color: rgb(0,0,0)\"> loadImage(url, callback) <\/span><span style=\"border-bottom: rgb(128,128,128) 1px solid; border-left: rgb(128,128,128) 1px solid; background-color: rgb(255,255,255); display: none; border-top: rgb(128,128,128) 1px solid; border-right: rgb(128,128,128) 1px solid\"><img decoding=\"async\" alt=\"\" src=\"http:\/\/www.cnblogs.com\/Images\/dot.gif\" \/><\/span><span><span style=\"color: rgb(0,0,0)\">{<br \/>\n<img decoding=\"async\" alt=\"\" align=\"top\" src=\"http:\/\/www.cnblogs.com\/Images\/OutliningIndicators\/InBlock.gif\" \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: rgb(0,0,255)\">var<\/span><span style=\"color: rgb(0,0,0)\"> img <\/span><span style=\"color: rgb(0,0,0)\">=<\/span><span style=\"color: rgb(0,0,0)\"> <\/span><span style=\"color: rgb(0,0,255)\">new<\/span><span style=\"color: rgb(0,0,0)\"> Image(); <\/span><span style=\"color: rgb(0,128,0)\">\/\/<\/span><span style=\"color: rgb(0,128,0)\">\u521b\u5efa\u4e00\u4e2aImage\u5bf9\u8c61\uff0c\u5b9e\u73b0\u56fe\u7247\u7684\u9884\u4e0b\u8f7d<\/span><span style=\"color: rgb(0,128,0)\"><br \/>\n<img decoding=\"async\" alt=\"\" align=\"top\" src=\"http:\/\/www.cnblogs.com\/Images\/OutliningIndicators\/InBlock.gif\" \/><\/span><span style=\"color: rgb(0,0,0)\">&nbsp;&nbsp;&nbsp;&nbsp; img.src <\/span><span style=\"color: rgb(0,0,0)\">=<\/span><span style=\"color: rgb(0,0,0)\"> url;<br \/>\n<img decoding=\"async\" alt=\"\" align=\"top\" src=\"http:\/\/www.cnblogs.com\/Images\/OutliningIndicators\/InBlock.gif\" \/>&nbsp;&nbsp;&nbsp;<br \/>\n<img decoding=\"async\" alt=\"\" align=\"top\" src=\"http:\/\/www.cnblogs.com\/Images\/OutliningIndicators\/ExpandedSubBlockStart.gif\" \/><img decoding=\"async\" alt=\"\" align=\"top\" style=\"display: none\" src=\"http:\/\/www.cnblogs.com\/Images\/OutliningIndicators\/ContractedSubBlock.gif\" \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: rgb(0,0,255)\">if<\/span><span style=\"color: rgb(0,0,0)\"> (img.complete) <\/span><span style=\"border-bottom: rgb(128,128,128) 1px solid; border-left: rgb(128,128,128) 1px solid; background-color: rgb(255,255,255); display: none; border-top: rgb(128,128,128) 1px solid; border-right: rgb(128,128,128) 1px solid\"><img decoding=\"async\" alt=\"\" src=\"http:\/\/www.cnblogs.com\/Images\/dot.gif\" \/><\/span><span><span style=\"color: rgb(0,0,0)\">{ <\/span><span style=\"color: rgb(0,128,0)\">\/\/<\/span><span style=\"color: rgb(0,128,0)\"> \u5982\u679c\u56fe\u7247\u5df2\u7ecf\u5b58\u5728\u4e8e\u6d4f\u89c8\u5668\u7f13\u5b58\uff0c\u76f4\u63a5\u8c03\u7528\u56de\u8c03\u51fd\u6570<\/span><span style=\"color: rgb(0,128,0)\"><br \/>\n<img decoding=\"async\" alt=\"\" align=\"top\" src=\"http:\/\/www.cnblogs.com\/Images\/OutliningIndicators\/InBlock.gif\" \/><\/span><span style=\"color: rgb(0,0,0)\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; callback.call(img);<br \/>\n<img decoding=\"async\" alt=\"\" align=\"top\" src=\"http:\/\/www.cnblogs.com\/Images\/OutliningIndicators\/InBlock.gif\" \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: rgb(0,0,255)\">return<\/span><span style=\"color: rgb(0,0,0)\">; <\/span><span style=\"color: rgb(0,128,0)\">\/\/<\/span><span style=\"color: rgb(0,128,0)\"> \u76f4\u63a5\u8fd4\u56de\uff0c\u4e0d\u7528\u518d\u5904\u7406onload\u4e8b\u4ef6<\/span><span style=\"color: rgb(0,128,0)\"><br \/>\n<img decoding=\"async\" alt=\"\" align=\"top\" src=\"http:\/\/www.cnblogs.com\/Images\/OutliningIndicators\/ExpandedSubBlockEnd.gif\" \/><\/span><span style=\"color: rgb(0,0,0)\">&nbsp;&nbsp;&nbsp;&nbsp; }<\/span><\/span><span style=\"color: rgb(0,0,0)\"><br \/>\n<img decoding=\"async\" alt=\"\" align=\"top\" src=\"http:\/\/www.cnblogs.com\/Images\/OutliningIndicators\/InBlock.gif\" \/><br \/>\n<img decoding=\"async\" alt=\"\" align=\"top\" src=\"http:\/\/www.cnblogs.com\/Images\/OutliningIndicators\/ExpandedSubBlockStart.gif\" \/><img decoding=\"async\" alt=\"\" align=\"top\" style=\"display: none\" src=\"http:\/\/www.cnblogs.com\/Images\/OutliningIndicators\/ContractedSubBlock.gif\" \/>&nbsp;&nbsp;&nbsp;&nbsp; img.onload <\/span><span style=\"color: rgb(0,0,0)\">=<\/span><span style=\"color: rgb(0,0,0)\"> <\/span><span style=\"color: rgb(0,0,255)\">function<\/span><span style=\"color: rgb(0,0,0)\"> () <\/span><span style=\"border-bottom: rgb(128,128,128) 1px solid; border-left: rgb(128,128,128) 1px solid; background-color: rgb(255,255,255); display: none; border-top: rgb(128,128,128) 1px solid; border-right: rgb(128,128,128) 1px solid\"><img decoding=\"async\" alt=\"\" src=\"http:\/\/www.cnblogs.com\/Images\/dot.gif\" \/><\/span><span><span style=\"color: rgb(0,0,0)\">{ <\/span><span style=\"color: rgb(0,128,0)\">\/\/<\/span><span style=\"color: rgb(0,128,0)\">\u56fe\u7247\u4e0b\u8f7d\u5b8c\u6bd5\u65f6\u5f02\u6b65\u8c03\u7528callback\u51fd\u6570\u3002<\/span><span style=\"color: rgb(0,128,0)\"><br \/>\n<img decoding=\"async\" alt=\"\" align=\"top\" src=\"http:\/\/www.cnblogs.com\/Images\/OutliningIndicators\/InBlock.gif\" \/><\/span><span style=\"color: rgb(0,0,0)\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; callback.call(img);<\/span><span style=\"color: rgb(0,128,0)\">\/\/<\/span><span style=\"color: rgb(0,128,0)\">\u5c06\u56de\u8c03\u51fd\u6570\u7684this\u66ff\u6362\u4e3aImage\u5bf9\u8c61<\/span><span style=\"color: rgb(0,128,0)\"><br \/>\n<img decoding=\"async\" alt=\"\" align=\"top\" src=\"http:\/\/www.cnblogs.com\/Images\/OutliningIndicators\/ExpandedSubBlockEnd.gif\" \/><\/span><span style=\"color: rgb(0,0,0)\">&nbsp;&nbsp;&nbsp;&nbsp; }<\/span><\/span><span style=\"color: rgb(0,0,0)\">;<br \/>\n<img decoding=\"async\" alt=\"\" align=\"top\" src=\"http:\/\/www.cnblogs.com\/Images\/OutliningIndicators\/ExpandedBlockEnd.gif\" \/>}<\/span><\/span><span style=\"color: rgb(0,0,0)\">;<\/span><\/div>\n<p>\n\u7ecf\u8fc7\u8fd9\u4e48\u4e00\u756a\u6298\u817e\uff0c\u603b\u7b97\u662f\u8ba9\u5404\u4e2a\u6d4f\u89c8\u5668\u90fd\u80fd\u6ee1\u8db3\u6211\u4eec\u7684\u76ee\u6807\u4e86\u3002\u867d\u7136\u4ee3\u7801\u5f88\u7b80\u5355\uff0c\u4f46\u662f\u5374\u628a\u56fe\u7247\u6d4f\u89c8\u5668\u4e2d\u6700\u6838\u5fc3\u7684\u95ee\u9898\u89e3\u51b3\u6389\u4e86\uff0c\u63a5\u4e0b\u6765\u4f60\u6240\u8981\u505a\u7684\uff0c\u4ec5\u4ec5\u662f\u56fe\u7247\u5982\u4f55\u5448\u73b0\u7684\u95ee\u9898\u4e86<\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u7f51\u7ad9\u5f00\u53d1\u65f6\u7ecf\u5e38\u9700\u8981\u5728\u67d0\u4e2a\u9875\u9762\u9700\u8981\u5b9e\u73b0\u5bf9\u5927\u91cf\u56fe\u7247\u7684\u6d4f\u89c8\uff0c\u5982\u679c\u8003\u8651\u6d41\u91cf\u7684\u8bdd\uff0c\u5927\u53ef\u4ee5\u50cfpconline\u4e00\u6837\u6bcf\u4e2a\u9875\u9762\u53ea\u663e\u793a\u4e00\u5f20\u56fe\u7247\uff0c\u8ba9\u7528\u6237\u6bcf\u770b\u4e00\u5f20\u56fe\u7247\u5c31\u9700\u8981\u91cd\u65b0\u4e0b\u8f7d\u4e00\u4e0b\u6574\u4e2a\u9875\u9762\u3002\u4e0d\u8fc7\uff0c\u5728web2.0\u65f6\u4ee3\uff0c\u66f4\u591a\u4eba\u613f\u610f\u7528javascript\u6765\u5b9e\u73b0\u4e00\u4e2a\u56fe&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"topic":[],"class_list":["post-819","post","type-post","status-publish","format-standard","hentry","category-technology"],"_links":{"self":[{"href":"http:\/\/www.xiaoyebailong.com\/index.php\/wp-json\/wp\/v2\/posts\/819","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.xiaoyebailong.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.xiaoyebailong.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.xiaoyebailong.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.xiaoyebailong.com\/index.php\/wp-json\/wp\/v2\/comments?post=819"}],"version-history":[{"count":1,"href":"http:\/\/www.xiaoyebailong.com\/index.php\/wp-json\/wp\/v2\/posts\/819\/revisions"}],"predecessor-version":[{"id":66641,"href":"http:\/\/www.xiaoyebailong.com\/index.php\/wp-json\/wp\/v2\/posts\/819\/revisions\/66641"}],"wp:attachment":[{"href":"http:\/\/www.xiaoyebailong.com\/index.php\/wp-json\/wp\/v2\/media?parent=819"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.xiaoyebailong.com\/index.php\/wp-json\/wp\/v2\/categories?post=819"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.xiaoyebailong.com\/index.php\/wp-json\/wp\/v2\/tags?post=819"},{"taxonomy":"topic","embeddable":true,"href":"http:\/\/www.xiaoyebailong.com\/index.php\/wp-json\/wp\/v2\/topic?post=819"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}