{"id":8,"date":"2007-05-20T23:36:22","date_gmt":"2007-05-21T03:36:22","guid":{"rendered":"http:\/\/prglab.com\/blog\/?page_id=8"},"modified":"2013-09-17T14:48:36","modified_gmt":"2013-09-17T18:48:36","slug":"js-howtouse","status":"publish","type":"page","link":"https:\/\/www.prglab.com\/blog\/js-tutorial\/js-howtouse","title":{"rendered":"\u600e\u6837\u4f7f\u7528JavaScript"},"content":{"rendered":"<p>\u6211\u4eec\u4f7f\u7528HTML\u6807\u8bb0\u7b26 &lt;script&gt; \u6765\u5728HTML\u9875\u9762\u4e2d\u63d2\u5165JS(JavaScript)\u811a\u672c<\/p>\n<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br \/>\n<strong>\u600e\u6837\u5728HTML\u9875\u9762\u4e2d\u63d2\u5165JS\u811a\u672c<\/strong><\/p>\n<p>\u5c06\u4ee5\u4e0b\u4ee3\u7801\u62f7\u8d1d\u5230\u4e00\u4e2a\u6587\u672c\u7f16\u8f91\u5668\u4e2d\uff0c\u5e76\u4fdd\u5b58\u4e3ahelloworld.html\u6587\u4ef6\uff1a<\/p>\n<table border=\"0\" cellspacing=\"1\" cellpadding=\"3\" width=\"96%\" align=\"center\">\n<tbody>\n<tr>\n<td class=\"quote\">&lt;html&gt;<br \/>\n&lt;body&gt;<span style=\"color: red\"><br \/>\n&lt;script type=&#8221;text\/javascript&#8221;&gt;<br \/>\ndocument.write(&#8220;\u55e8\uff0c\u4f60\u597d\uff01&#8221;)<br \/>\n&lt;\/script&gt;<\/span><br \/>\n&lt;\/body&gt;<br \/>\n&lt;\/html&gt;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u7528\u6d4f\u89c8\u5668\u6253\u5f00\u8fd9\u4e2ahelloworld.html\u6587\u4ef6\uff0c\u4f60\u4f1a\u770b\u5230\u6d4f\u89c8\u5668\u4e2d\u663e\u793a\u4ee5\u4e0b\u8f93\u51fa\uff1a<\/p>\n<table border=\"0\" cellspacing=\"1\" cellpadding=\"3\" width=\"96%\" align=\"center\">\n<tbody>\n<tr>\n<td class=\"quote\"><span style=\"color: red\">\u55e8\uff0c\u4f60\u597d\uff01<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><strong>\u5bf9\u4e0a\u9762\u4f8b\u5b50\u7684\u89e3\u91ca<\/strong><br \/>\n\u6211\u4eec\u4f7f\u7528\u6807\u8bb0\u7b26&lt;script&gt;\u6765\u5c06JS\u811a\u672c\u63d2\u5165HTML\u9875\u9762\u4e2d\uff0c\u5e76\u4f7f\u7528\u4e86\u7c7b\u578b\u5c5e\u6027(type)\u6765\u5b9a\u4e49\u811a\u672c\u8bed\u8a00\u7684\u7c7b\u578b\u4e3aJavaScript\u3002<br \/>\n\u56e0\u6b64\uff0c&lt;script type=&#8221;text\/javascript&#8221;&gt; \u548c &lt;\/script&gt; \u5b9a\u4e49\u4e86JavaScript \u5f00\u59cb\u548c\u7ed3\u675f\u7684\u4f4d\u7f6e\uff1a<\/p>\n<table border=\"0\" cellspacing=\"1\" cellpadding=\"3\" width=\"96%\" align=\"center\">\n<tbody>\n<tr>\n<td class=\"quote\">&lt;html&gt;<br \/>\n&lt;body&gt;<span style=\"color: red\"><br \/>\n&lt;script type=&#8221;text\/javascript&#8221;&gt;<br \/>\n\u3002\u3002\u3002\u6b64\u5904\u811a\u672c\u7701\u7565\u82e5\u5e72\u3002\u3002\u3002<br \/>\n&lt;\/script&gt;<\/span><br \/>\n&lt;\/body&gt;<br \/>\n&lt;\/html&gt;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u8bed\u53e5 document.write \u662f\u4e00\u4e2a\u6807\u51c6\u7684 JavaScript \u547d\u4ee4\uff0c\u7528\u6765\u5411\u9875\u9762\u5199\u8f93\u51fa\u3002<\/p>\n<p>\u901a \u8fc7\u5728\u6807\u8bb0\u7b26&lt;script type=&#8221;text\/javascript&#8221;&gt; \u548c &lt;\/script&gt; \u4e4b\u95f4\u4f7f\u7528document.write\uff0c\u6d4f\u89c8\u5668\u4f1a\u8fa8\u8ba4\u51fa\u8fd9\u662f\u4e00\u6bb5JavaScript\u547d\u4ee4\uff0c\u4ece\u800c\u6267\u884c\u5176\u4e2d\u7684\u547d\u4ee4\u884c\u3002\u5728\u4e0b\u9762\u8fd9\u4e2a\u4f8b\u5b50\u91cc\uff0c\u6d4f\u89c8\u5668\u4f1a\u5728\u9875\u9762\u4e2d\u5199\u51fa<span style=\"color: red;\">\u6b22\u8fce\u6765\u8bbf\uff01<span style=\"color: #000000;\">\u7684\u5b57\u6837\u3002<\/span><\/span><\/p>\n<table border=\"0\" cellspacing=\"1\" cellpadding=\"3\" width=\"96%\" align=\"center\">\n<tbody>\n<tr>\n<td class=\"quote\">&lt;html&gt;<br \/>\n&lt;body&gt;<span style=\"color: red\"><br \/>\n&lt;script type=&#8221;text\/javascript&#8221;&gt;<br \/>\ndocument.write(&#8220;<\/span><span style=\"color: red;\">\u6b22\u8fce\u6765\u8bbf\uff01<\/span><span style=\"color: red\">&#8220;)<br \/>\n&lt;\/script&gt;<\/span><br \/>\n&lt;\/body&gt;<br \/>\n&lt;\/html&gt;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><strong>\u6ce8\u610f:<\/strong> \u5982\u679c\u6ca1\u6709\u4f7f\u7528\u6807\u8bb0\u7b26 &lt;script&gt; \uff0c\u6d4f\u89c8\u5668\u4f1a\u5c06\u547d\u4ee4\u884cdocument.write(<span style=\"color: #ff0000;\">&#8220;\u6b22\u8fce\u6765\u8bbf\uff01&#8221;<\/span>) \u5f53\u4f5c\u7eaf\u6587\u672c\u5bf9\u5f85\uff0c\u90a3\u4e48\u6574\u884c\u5185\u5bb9\u5305\u62ecdocument.write\u547d\u4ee4\u90fd\u4f1a\u5728\u9875\u9762\u4e0a\u88ab\u6253\u5370\u51fa\u6765\u3002<\/p>\n<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br \/>\n<strong>JavaScript\u8bed\u53e5\u7ed3\u675f\u9700\u8981\u5206\u53f7\u5417\uff1f<\/strong><\/p>\n<p>\u4f20\u7edf\u7f16\u7a0b\u8bed\u8a00\uff0c\u4f8b\u5982 C++ \u548c Java\uff0c\u6bcf\u4e00\u6761\u8bed\u53e5\u90fd\u9700\u8981\u4ee5\u5206\u53f7\u7ed3\u675f\u3002<\/p>\n<p>\u8bb8\u591a\u7a0b\u5e8f\u5458\u5728\u5199JavaScript\u7684\u65f6\u5019\u4ecd\u4fdd\u6301\u4e86\u8fd9\u4e00\u4e60\u60ef\u3002\u5b9e\u9645\u4e0a\u5728JavaScript\u4e2d\u5206\u53f7\u5e76<strong>\u4e0d\u662f\u5fc5\u9700<\/strong>\u7684\u3002\u4f46\u662f\u5982\u679c\u4f60\u628a\u591a\u6761JavaScript\u8bed\u53e5\u5199\u5728\u540c\u4e00\u884c\u91cc\u5219\u9700\u8981\u4ee5\u5206\u53f7\u5206\u9694\u3002<\/p>\n<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br \/>\n<strong>\u5173\u4e8e\u65e7\u7248\u6d4f\u89c8\u5668\u95ee\u9898<\/strong><\/p>\n<p>\u65e7\u7248\uff08\u5f88\u65e7\u5f88\u65e7\u7684\u7248\uff09\u6d4f\u89c8\u5668\u4e0d\u652f\u6301JavaScript\uff0c\u4f1a\u628aJS\u811a\u672c\u663e\u793a\u4e3a\u9875\u9762\u5185\u5bb9\u3002\u4e3a\u907f\u514d\u8fd9\u79cd\u60c5\u51b5\u53d1\u751f\uff0c \u5728Javascript\u521a\u5f00\u59cb\u51fa\u73b0\u7684\u5e74\u4ee3\uff0c\u53ef\u4ee5\u770b\u5230\u5f88\u591a\u5efa\u8bae\u4f7f\u7528 HTML \u7684\u6ce8\u91ca\u6807\u793a\u7b26\u5c06JS\u811a\u672c\u5305\u8d77\u6765\uff1a<\/p>\n<table border=\"0\" cellspacing=\"1\" cellpadding=\"3\" width=\"96%\" align=\"center\">\n<tbody>\n<tr>\n<td class=\"quote\">&lt;script type=&#8221;text\/javascript&#8221;&gt;<br \/>\n<span style=\"color: red\">&lt;!&#8211;<br \/>\ndocument.write(&#8220;<\/span><span style=\"color: red\">\u55e8\uff0c\u4f60\u597d\uff01&#8221;<\/span><span style=\"color: red\">)<br \/>\n\/\/&#8211;&gt;<\/span><br \/>\n&lt;\/script&gt;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u6ce8\u91ca\u7ed3\u675f\u884c\u524d\u9762\u7684\u53cc\u659c\u7ebf (\/\/) \u662fJavaScript \u7684\u6ce8\u91ca\u7b26\u3002\u8fd9\u6837\u5199\u53ef\u4ee5\u9632\u6b62JavaScript \u7f16\u8bd1\u5668\u628a\u8fd9\u4e00\u884c\u5f53\u4f5cJS\u811a\u672c\u8fdb\u884c\u7f16\u8bd1\u3002<\/p>\n<p><span style=\"color: #333399;\">\u4f46\u73b0\u5728\u5b9e\u9645\u4e0a\u8fd9\u5df2\u7ecf\u4e0d\u88ab\u5e7f\u6cdb\u5efa\u8bae\u4f7f\u7528\u4e86\u3002\u4e3a\u4ec0\u4e48\u5462\uff1f\u56e0\u4e3a\uff1a\u7b2c\u4e00\u65e7\u7248\u4e3b\u8981\u662f\u6307\u76841995\u5e74\u4ee5\u524d\u7684\u6d4f\u89c8\u5668\u7248\u672c\uff0c\u4f8b\u5982\u7f51\u666f1(Netscape 1)\uff0cMozaic\uff0cIE 1\uff0c\u548c IE 2\uff0c\u8fd9\u4e9b\u6d4f\u89c8\u5668\u73b0\u5728\u51e0\u7ecf\u51e0\u4e4e\u6ca1\u6709\u4eba\u4f7f\u7528\u4e86\u3002\u7b2c\u4e8c\uff0c\u4e5f\u662f\u6700\u91cd\u8981\u7684\u4e00\u70b9\uff0c\u5728XHTML\u4e2d\uff0c\u88abHTML\u6ce8\u91ca\u5305\u56f4\u7684JS\u4ee3\u7801\u4f1a\u771f\u7684\u88ab\u5f53\u4f5c\u6ce8\u91ca\u5904\u7406\u6389\uff0c\u4e0d\u518d\u8d77\u4f5c\u7528\u3002\u5982\u679c\u6709\u4e00\u5929\u4f60\u51b3\u5b9a\u5c06\u4f60\u7684\u7f51\u9875\u4f5c\u4e3aXHTML\u6765\u4f9b\u8bbf\u5ba2\u6d4f\u89c8\uff0c\u90a3\u4e48\u88ab\u6ce8\u91ca\u8d77\u6765\u7684JS\u4ee3\u7801\u4f1a\u5168\u90e8\u5931\u6548\uff0c\u6240\u4ee5\u8981\u5c0f\u5fc3\u4f7f\u7528\u3002<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6211\u4eec\u4f7f\u7528HTML\u6807\u8bb0\u7b26 &lt;script&gt; \u6765\u5728HTML\u9875\u9762\u4e2d\u63d2\u5165JS(JavaScript)\u811a\u672c &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;- \u600e\u6837\u5728HTML\u9875\u9762\u4e2d\u63d2\u5165JS\u811a\u672c \u5c06\u4ee5\u4e0b\u4ee3\u7801\u62f7\u8d1d\u5230\u4e00\u4e2a\u6587\u672c\u7f16\u8f91\u5668\u4e2d\uff0c\u5e76\u4fdd\u5b58\u4e3ahelloworld.html\u6587\u4ef6\uff1a &lt;html&gt; &lt;body&gt; &lt;script type=&#8221;text\/javascript&#8221;&gt; document.write(&#8220;\u55e8\uff0c\u4f60\u597d\uff01&#8221;) &lt;\/script&gt; &lt;\/body&gt; &lt;\/html&gt; \u7528\u6d4f\u89c8\u5668\u6253\u5f00\u8fd9\u4e2ahelloworld.html\u6587\u4ef6\uff0c\u4f60\u4f1a\u770b\u5230\u6d4f\u89c8\u5668\u4e2d\u663e\u793a\u4ee5\u4e0b\u8f93\u51fa\uff1a \u55e8\uff0c\u4f60\u597d\uff01 \u5bf9\u4e0a\u9762\u4f8b\u5b50\u7684\u89e3\u91ca \u6211\u4eec\u4f7f\u7528\u6807\u8bb0\u7b26&lt;script&gt;\u6765\u5c06JS\u811a\u672c\u63d2\u5165HTML\u9875\u9762\u4e2d\uff0c\u5e76\u4f7f\u7528\u4e86\u7c7b\u578b\u5c5e\u6027(type)\u6765\u5b9a\u4e49\u811a\u672c\u8bed\u8a00\u7684\u7c7b\u578b\u4e3aJavaScript\u3002 \u56e0\u6b64\uff0c&lt;script type=&#8221;text\/javascript&#8221;&gt; \u548c &lt;\/script&gt; \u5b9a\u4e49\u4e86JavaScript \u5f00\u59cb\u548c\u7ed3\u675f\u7684\u4f4d\u7f6e\uff1a &lt;html&gt; &lt;body&gt; &lt;script type=&#8221;text\/javascript&#8221;&gt; \u3002\u3002\u3002\u6b64\u5904\u811a\u672c\u7701\u7565\u82e5\u5e72\u3002\u3002\u3002 &lt;\/script&gt; &lt;\/body&gt; &lt;\/html&gt; \u8bed\u53e5 document.write \u662f\u4e00\u4e2a\u6807\u51c6\u7684 JavaScript \u547d\u4ee4\uff0c\u7528\u6765\u5411\u9875\u9762\u5199\u8f93\u51fa\u3002 \u901a \u8fc7\u5728\u6807\u8bb0\u7b26&lt;script type=&#8221;text\/javascript&#8221;&gt; \u548c &lt;\/script&gt; \u4e4b\u95f4\u4f7f\u7528document.write\uff0c\u6d4f\u89c8\u5668\u4f1a\u8fa8\u8ba4\u51fa\u8fd9\u662f\u4e00\u6bb5JavaScript\u547d\u4ee4\uff0c\u4ece\u800c\u6267\u884c\u5176\u4e2d\u7684\u547d\u4ee4\u884c\u3002\u5728\u4e0b\u9762\u8fd9\u4e2a\u4f8b\u5b50\u91cc\uff0c\u6d4f\u89c8\u5668\u4f1a\u5728\u9875\u9762\u4e2d\u5199\u51fa\u6b22\u8fce\u6765\u8bbf\uff01\u7684\u5b57\u6837\u3002 &lt;html&gt; &lt;body&gt; &lt;script type=&#8221;text\/javascript&#8221;&gt; document.write(&#8220;\u6b22\u8fce\u6765\u8bbf\uff01&#8220;) &lt;\/script&gt; &lt;\/body&gt; &lt;\/html&gt; \u6ce8\u610f: \u5982\u679c\u6ca1\u6709\u4f7f\u7528\u6807\u8bb0\u7b26 &lt;script&gt; \uff0c\u6d4f\u89c8\u5668\u4f1a\u5c06\u547d\u4ee4\u884cdocument.write(&#8220;\u6b22\u8fce\u6765\u8bbf\uff01&#8221;) [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":3,"menu_order":1,"comment_status":"open","ping_status":"open","template":"","meta":[],"_links":{"self":[{"href":"https:\/\/www.prglab.com\/blog\/wp-json\/wp\/v2\/pages\/8"}],"collection":[{"href":"https:\/\/www.prglab.com\/blog\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.prglab.com\/blog\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.prglab.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.prglab.com\/blog\/wp-json\/wp\/v2\/comments?post=8"}],"version-history":[{"count":12,"href":"https:\/\/www.prglab.com\/blog\/wp-json\/wp\/v2\/pages\/8\/revisions"}],"predecessor-version":[{"id":274,"href":"https:\/\/www.prglab.com\/blog\/wp-json\/wp\/v2\/pages\/8\/revisions\/274"}],"up":[{"embeddable":true,"href":"https:\/\/www.prglab.com\/blog\/wp-json\/wp\/v2\/pages\/3"}],"wp:attachment":[{"href":"https:\/\/www.prglab.com\/blog\/wp-json\/wp\/v2\/media?parent=8"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}