{"id":1430,"date":"2012-02-21T16:45:28","date_gmt":"2012-02-21T08:45:28","guid":{"rendered":"http:\/\/doophp.sinaapp.com\/?p=1430"},"modified":"2012-02-21T17:23:44","modified_gmt":"2012-02-21T09:23:44","slug":"javascript-block-html","status":"publish","type":"post","link":"https:\/\/blog.vimge.com\/archives\/front-end\/javascript-block-html.html","title":{"rendered":"\u907f\u514dJavaScript\u963b\u585e\u9875\u9762\u9010\u6b65\u663e\u793a\u95ee\u9898"},"content":{"rendered":"

\u5c3d\u7ba1\u4e3b\u6d41\u6d4f\u89c8\u5668\u90fd\u652f\u6301\u5e76\u884c\u4e0b\u8f7d\uff0c\u4f46\u4e8b\u5b9e\u60c5\u51b5\u662f\u5728\u4e0b\u8f7d\u811a\u672c\u65f6\u5e76\u884c\u4e0b\u8f7d\u662f\u88ab\u7981\u7528\u7684\uff0c\u5373\u4f7f\u4f7f\u7528\u4e86\u4e0d\u540c\u7684\u4e3b\u673a\u540d\uff0c\u6d4f\u89c8\u5668\u4e5f\u4e0d\u4f1a\u542f\u52a8\u5176\u4ed6\u7684\u4e0b\u8f7d\uff0c\u89e3\u91ca\u662f\u4e3a\u4e86\u4fdd\u8bc1\u811a\u672c\u80fd\u591f\u6309\u7167\u6b63\u786e\u7684\u987a\u5e8f\u6267\u884c\uff0c\u4ee5\u53ca\u811a\u672c\u53ef\u80fd\u4f7f\u7528document.write\u6765\u4fee\u6539\u9875\u9762\u5185\u5bb9\u3002<\/p>\n

\u5728\u9875\u9762\u4f7f\u7528\u811a\u672c\u65f6\uff0c\u5bf9\u4e8e\u6240\u6709\u4f4d\u4e8e\u811a\u672c\u4ee5\u4e0b\u7684\u5185\u5bb9\uff0c\u9875\u9762\u7684\u9010\u6b65\u5448\u73b0\u90fd\u88ab\u963b\u585e\u5c24\u5176\u7684\u5728\u8c03\u7528\u5916\u90e8\u811a\u672c\u7684\u65f6\u5019\uff0c\u56e0\u4e3a\u901f\u5ea6\u539f\u56e0\u5bfc\u81f4\u9875\u9762\u534a\u5929\u4e0d\u80fd\u6b63\u5e38\u663e\u793a\u5c24\u4e3a\u660e\u663e\u3002\u901a\u5e38\u6211\u4eec\u4f1a\u811a\u672c\u653e\u5728\u9875\u9762\u6700\u9760\u4e0b\u6807\u7b7e\u4e4b\u524d\u7684\u5730\u65b9\uff0c\u4ee5\u671f\u5c3d\u53ef\u4ee5\u591a\u7684\u5185\u5bb9\u80fd\u591f\u9010\u6b65\u5448\u73b0\u3002<\/p>\n

\u5c3d\u7ba1\u5728\u5927\u591a\u60c5\u51b5\u4e0b\u6211\u4eec\u53ef\u4ee5\u628a\u52a8\u6001\u8c03\u7528\u5185\u5bb9\u7684\u811a\u672c\u653e\u5728\u4e4b\u524d\uff0c\u4f46\u6709\u65f6\u5019\u60c5\u51b5\u5e76\u4e0d\u662f\u90a3\u4e48\u4e50\u89c2\uff0c\u5728MVC\u5206\u5c42\u6d41\u884c\u7684\u4eca\u5929\uff0c\u6a21\u677f\u5e94\u7528\u5982\u6b64\u666e\u53ca\u7684\u60c5\u51b5\u4e0b\uff0c\u6709\u65f6\u5019\u6211\u4eec\u4e0d\u5f97\u4e0d\u628a\u811a\u672c\u653e\u5728\u9875\u9762\u4e2d\u95f4\uff0c\u811a\u672c\u963b\u585e\u5185\u5bb9\u9010\u6b65\u5448\u73b0\u95ee\u9898\u518d\u4e00\u6b21\u51fa\u73b0\u3002<\/p>\n

\u52a0\u8f7d\u540e\u52a0\u8f7d<\/strong>
\n\u7ecf\u8fc7\u672c\u4eba\u9a8c\u8bc1\uff0c\u901a\u8fc7JavaScript\u5b9a\u65f6\u8bed\u53e5\u6267\u884c\u52a0\u8f7d\u52a8\u4f5c\uff0c”document.createElement(“script”)\u52a8\u6001\u751f\u6210\u5185\u5bb9\u52a0\u8f7d\u5916\u90e8JavaScript\u811a\u672c\u53ef\u4ee5\u89e3\u51b3\u9875\u9762\u9010\u6b65\u5448\u73b0\u95ee\u9898\u3002\u4ee3\u7801\u5982\u4e0b\uff1a
\n[code]
\n<script language="javascript">
\n\tsetTimeout(‘loadNews()’, 1); \/\/\u5b9a\u65f6\u6267\u884c\u52a8\u6001\u52a0\u8f7d
\n\tfunction loadNews(){
\n\t\tvar elem = document.createElement("script");
\n\t\telem.src = "\/index.php?m=house&q=news";
\n\t\tdocument.body.appendChild(elem);
\n\t}
\n<\/script>
\n[\/code]<\/p>\n

\u8fd9\u6837\u5728\u9875\u9762\u52a0\u8f7d\u5b8c\u6210\u4e4b\u540eJavaScript\u52a0\u8f7d\u672a\u5b8c\u6210\u4e4b\u524d\uff0c\u9875\u9762\u9010\u6b65\u5448\u73b0\u907f\u514d\u963b\u585e\u663e\u793a\u3002<\/p>\n

\u6b64\u65b9\u6cd5\u7684\u7f3a\u9677\u662f\u811a\u672c\u52a0\u8f7d\u5b8c\u4e4b\u524d\u6d4f\u89c8\u5668\u4e00\u5b9a\u663e\u793a\u9875\u9762\u52a0\u8f7d\u4e2d\uff0c\u76f4\u5230\u811a\u672c\u52a0\u8f7d\u5b8c\u6210\u3002<\/p>\n

\u811a\u672c\u901a\u8fc7IE7\/Chrome\/Firefox\u9a8c\u8bc1\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

\u5c3d\u7ba1\u4e3b\u6d41\u6d4f\u89c8\u5668\u90fd\u652f\u6301\u5e76\u884c\u4e0b\u8f7d\uff0c\u4f46\u4e8b\u5b9e\u60c5\u51b5\u662f\u5728\u4e0b\u8f7d\u811a\u672c\u65f6\u5e76\u884c\u4e0b\u8f7d\u662f\u88ab\u7981\u7528\u7684\uff0c\u5373\u4f7f\u4f7f\u7528\u4e86\u4e0d\u540c\u7684\u4e3b\u673a\u540d\uff0c\u6d4f\u89c8\u5668\u4e5f\u4e0d\u4f1a […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[6],"tags":[52,53],"_links":{"self":[{"href":"https:\/\/blog.vimge.com\/wp-json\/wp\/v2\/posts\/1430"}],"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=1430"}],"version-history":[{"count":4,"href":"https:\/\/blog.vimge.com\/wp-json\/wp\/v2\/posts\/1430\/revisions"}],"predecessor-version":[{"id":1434,"href":"https:\/\/blog.vimge.com\/wp-json\/wp\/v2\/posts\/1430\/revisions\/1434"}],"wp:attachment":[{"href":"https:\/\/blog.vimge.com\/wp-json\/wp\/v2\/media?parent=1430"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.vimge.com\/wp-json\/wp\/v2\/categories?post=1430"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.vimge.com\/wp-json\/wp\/v2\/tags?post=1430"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}