{"id":251,"date":"2009-03-08T16:37:00","date_gmt":"2009-03-08T08:37:00","guid":{"rendered":""},"modified":"2013-11-29T14:16:07","modified_gmt":"2013-11-29T06:16:07","slug":"javascript%e4%b8%ad%e7%9a%84%e4%ba%8b%e4%bb%b6%e8%af%a6%e8%a7%a3","status":"publish","type":"post","link":"https:\/\/kyle.ai\/blog\/251.html","title":{"rendered":"JavaScript\u4e2d\u7684\u4e8b\u4ef6\u8be6\u89e3"},"content":{"rendered":"<p>onblur \u4e8b\u4ef6 \u53d1\u751f\u5728\u7a97\u53e3\u5931\u53bb\u7126\u70b9\u7684\u65f6\u5019\u3002<\/p>\n<p>\u5e94\u7528\u4e8e\uff1awindow \u5bf9\u8c61<\/p>\n<p>onchange \u4e8b\u4ef6 \u53d1\u751f\u5728\u6587\u672c\u8f93\u5165\u533a\u7684\u5185\u5bb9\u88ab\u66f4\u6539\uff0c\u7136\u540e\u7126\u70b9\u4ece\u6587\u672c\u8f93\u5165\u533a\u79fb\u8d70\u4e4b\u540e\u3002\u6355\u6349\u6b64\u4e8b\u4ef6\u4e3b\u8981\u7528\u4e8e\u5b9e\u65f6\u68c0\u6d4b\u8f93\u5165\u7684\u6709\u6548\u6027\uff0c\u6216\u8005\u7acb\u523b\u6539\u53d8\u6587\u6863\u5185\u5bb9\u3002<\/p>\n<p>\u5e94\u7528\u4e8e\uff1aPassword \u5bf9\u8c61\uff1bSelect \u5bf9\u8c61\uff1bText \u5bf9\u8c61\uff1bTextarea \u5bf9\u8c61<\/p>\n<p>onclick \u4e8b\u4ef6 \u53d1\u751f\u5728\u5bf9\u8c61\u88ab\u5355\u51fb\u7684\u65f6\u5019\u3002\u5355\u51fb\u662f\u6307\u9f20\u6807\u505c\u7559\u5728\u5bf9\u8c61\u4e0a\uff0c\u6309\u4e0b\u9f20\u6807\u952e\uff0c\u6ca1\u6709\u79fb\u52a8\u9f20\u6807\u800c\u653e\u5f00\u9f20\u6807\u952e\u8fd9\u4e00\u4e2a\u5b8c\u6574\u7684\u8fc7\u7a0b\u3002<\/p>\n<p>\u4e00\u4e2a\u666e\u901a\u6309\u94ae\u5bf9\u8c61\uff08Button\uff09\u901a\u5e38\u4f1a\u6709 onclick \u4e8b\u4ef6\u5904\u7406\u7a0b\u5e8f\uff0c\u56e0\u4e3a\u8fd9\u79cd\u5bf9\u8c61\u6839\u672c\u4e0d\u80fd\u4ece\u7528\u6237\u90a3\u91cc\u5f97\u5230\u4efb\u4f55\u4fe1\u606f\uff0c\u6ca1\u6709 onclick \u4e8b\u4ef6\u5904\u7406\u7a0b\u5e8f\u5c31\u7b49\u4e8e\u5e9f\u67f4\u3002\u6309\u94ae\u4e0a\u6dfb\u52a0 onclick \u4e8b\u4ef6\u5904\u7406\u7a0b\u5e8f\uff0c\u53ef\u4ee5\u6a21\u62df\u201c\u53e6\u4e00\u4e2a\u63d0\u4ea4\u6309\u94ae\u201d\uff0c\u65b9\u6cd5\u662f\uff1a\u5728\u4e8b\u4ef6\u5904\u7406\u7a0b\u5e8f\u4e2d\u66f4\u6539\u8868\u5355\u7684 action, target, encoding, method \u7b49\u4e00\u4e2a\u6216\u51e0\u4e2a\u5c5e\u6027\uff0c\u7136\u540e\u8c03\u7528\u8868\u5355\u7684 submit() \u65b9\u6cd5\u3002<\/p>\n<p>\u5728 Link \u5bf9\u8c61\u7684 onclick \u4e8b\u4ef6\u5904\u7406\u7a0b\u5e8f\u4e2d\u8fd4\u56de false \u503c\uff08return false\uff09\uff0c\u80fd\u963b\u6b62\u6d4f\u89c8\u5668\u6253\u5f00\u6b64\u8fde\u63a5\u3002\u5373\uff0c\u5982\u679c\u6709\u4e00\u4e2a\u8fd9\u6837\u7684\u8fde\u63a5\uff1a<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;a href=&quot;http:\/\/www.a.com&quot; onclick=&quot;return false&quot;&gt;Go!&lt;\/a&gt;\uff0c\r\n<\/pre>\n<p>\u90a3\u4e48\u65e0\u8bba\u7528\u6237\u600e\u6837\u70b9\u51fb\uff0c\u90fd\u4e0d\u4f1a\u53bb\u5230 www.a.com \u7f51\u7ad9\uff0c\u9664\u975e\u7528\u6237\u7981\u6b62\u6d4f\u89c8\u5668\u8fd0\u884c JavaScript\u3002<\/p>\n<p>\u5e94\u7528\u4e8e\uff1aButton \u5bf9\u8c61\uff1bCheckbox \u5bf9\u8c61\uff1bImage \u5bf9\u8c61\uff1bLink \u5bf9\u8c61\uff1bRadio \u5bf9\u8c61\uff1bReset \u5bf9\u8c61\uff1bSubmit \u5bf9\u8c61<\/p>\n<p>onerror \u4e8b\u4ef6 \u53d1\u751f\u5728\u9519\u8bef\u53d1\u751f\u7684\u65f6\u5019\u3002\u5b83\u7684\u4e8b\u4ef6\u5904\u7406\u7a0b\u5e8f\u901a\u5e38\u5c31\u53eb\u505a\u201c\u9519\u8bef\u5904\u7406\u7a0b\u5e8f\u201d(Error Handler)\uff0c\u7528\u6765\u5904\u7406\u9519\u8bef\u3002\u4e0a\u8fb9\u5df2\u7ecf\u4ecb\u7ecd\u8fc7\uff0c\u8981\u5ffd\u7565\u4e00\u5207\u9519\u8bef\uff0c\u5c31\u4f7f\u7528\uff1a<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\nfunction ignoreError() {\r\nreturn true;\r\n}\r\n\r\nwindow.onerror = ignoreError;\r\n<\/pre>\n<p>\u5e94\u7528\u4e8e\uff1awindow \u5bf9\u8c61<\/p>\n<p>onfocus \u4e8b\u4ef6 \u53d1\u751f\u5728\u7a97\u53e3\u5f97\u5230\u7126\u70b9\u7684\u65f6\u5019\u3002<\/p>\n<p>\u5e94\u7528\u4e8e\uff1awindow \u5bf9\u8c61<\/p>\n<p>onload \u4e8b\u4ef6 \u53d1\u751f\u5728\u6587\u6863\u5168\u90e8\u4e0b\u8f7d\u5b8c\u6bd5\u7684\u65f6\u5019\u3002\u5168\u90e8\u4e0b\u8f7d\u5b8c\u6bd5\u610f\u5473\u7740\u4e0d\u4f46 HTML \u6587\u4ef6\uff0c\u800c\u4e14\u5305\u542b\u7684\u56fe\u7247\uff0c\u63d2\u4ef6\uff0c\u63a7\u4ef6\uff0c\u5c0f\u7a0b\u5e8f\u7b49\u5168\u90e8\u5185\u5bb9\u90fd\u4e0b\u8f7d\u5b8c\u6bd5\u3002\u672c\u4e8b\u4ef6\u662f window \u7684\u4e8b\u4ef6\uff0c\u4f46\u662f\u5728 HTML \u4e2d\u6307\u5b9a\u4e8b\u4ef6\u5904\u7406\u7a0b\u5e8f\u7684\u65f6\u5019\uff0c\u6211\u4eec\u662f\u628a\u5b83\u5199\u5728body\u6807\u8bb0\u4e2d\u7684\u3002<\/p>\n<p>\u5e94\u7528\u4e8e\uff1awindow \u5bf9\u8c61<\/p>\n<p>onmousedown \u4e8b\u4ef6 \u53d1\u751f\u5728\u7528\u6237\u628a\u9f20\u6807\u653e\u5728\u5bf9\u8c61\u4e0a\u6309\u4e0b\u9f20\u6807\u952e\u7684\u65f6\u5019\u3002\u53c2\u8003 onmouseup \u4e8b\u4ef6\u3002<\/p>\n<p>\u5e94\u7528\u4e8e\uff1aButton \u5bf9\u8c61\uff1bLink \u5bf9\u8c61<\/p>\n<p>onmouseout \u4e8b\u4ef6 \u53d1\u751f\u5728\u9f20\u6807\u79bb\u5f00\u5bf9\u8c61\u7684\u65f6\u5019\u3002\u53c2\u8003 onmouseover \u4e8b\u4ef6\u3002<\/p>\n<p>\u5e94\u7528\u4e8e\uff1aLink \u5bf9\u8c61<\/p>\n<p>onmouseover \u4e8b\u4ef6 \u53d1\u751f\u5728\u9f20\u6807\u8fdb\u5165\u5bf9\u8c61\u8303\u56f4\u7684\u65f6\u5019\u3002\u8fd9\u4e2a\u4e8b\u4ef6\u548c onmouseout \u4e8b\u4ef6\uff0c\u518d\u52a0\u4e0a\u56fe\u7247\u7684\u9884\u8bfb\uff0c\u5c31\u53ef\u4ee5\u505a\u5230\u5f53\u9f20\u6807\u79fb\u5230\u56fe\u50cf\u8fde\u63a5\u4e0a\uff0c\u56fe\u50cf\u66f4\u6539\u7684\u6548\u679c\u4e86\u3002\u6709\u65f6\u6211\u4eec\u770b\u5230\uff0c\u5728\u6307\u5411\u4e00\u4e2a\u8fde\u63a5\u65f6\uff0c\u72b6\u6001\u680f\u4e0a\u4e0d\u663e\u793a\u5730\u5740\uff0c\u800c\u663e\u793a\u5176\u5b83\u7684\u8d44\u6599\uff0c\u770b\u8d77\u6765\u8fd9\u4e9b\u8d44\u6599\u662f\u53ef\u4ee5\u968f\u65f6\u66f4\u6539\u7684\u3002\u5b83\u4eec\u662f\u8fd9\u6837\u505a\u51fa\u6765\u7684\uff1a<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;a href=&quot;...&quot;\r\nonmouseover=&quot;window.status='Click Me Please!'; return true;&quot;\r\nonmouseout=&quot;window.status=''; return true;&quot;&gt;\r\n<\/pre>\n<p>\u5e94\u7528\u4e8e\uff1aLink \u5bf9\u8c61<\/p>\n<p>onmouseup \u4e8b\u4ef6 \u53d1\u751f\u5728\u7528\u6237\u628a\u9f20\u6807\u653e\u5728\u5bf9\u8c61\u4e0a\u9f20\u6807\u952e\u88ab\u6309\u4e0b\u7684\u60c5\u51b5\u4e0b\uff0c\u653e\u5f00\u9f20\u6807\u952e\u7684\u65f6\u5019\u3002\u5982\u679c\u6309\u4e0b\u9f20\u6807\u952e\u7684\u65f6\u5019\uff0c\u9f20\u6807\u5e76\u4e0d\u5728\u653e\u5f00\u9f20\u6807\u7684\u5bf9\u8c61\u4e0a\uff0c\u5219\u672c\u4e8b\u4ef6\u4e0d\u4f1a\u53d1\u751f\u3002<\/p>\n<p>\u5e94\u7528\u4e8e\uff1aButton \u5bf9\u8c61\uff1bLink \u5bf9\u8c61<\/p>\n<p>onreset \u4e8b\u4ef6 \u53d1\u751f\u5728\u8868\u5355\u7684\u201c\u91cd\u7f6e\u201d\u6309\u94ae\u88ab\u5355\u51fb\uff08\u6309\u4e0b\u5e76\u653e\u5f00\uff09\u7684\u65f6\u5019\u3002\u901a\u8fc7\u5728\u4e8b\u4ef6\u5904\u7406\u7a0b\u5e8f\u4e2d\u8fd4\u56de false \u503c\uff08return false\uff09\u53ef\u4ee5\u963b\u6b62\u8868\u5355\u91cd\u7f6e\u3002<\/p>\n<p>\u5e94\u7528\u4e8e\uff1aForm \u5bf9\u8c61<\/p>\n<p>onresize \u4e8b\u4ef6 \u53d1\u751f\u5728\u7a97\u53e3\u88ab\u8c03\u6574\u5927\u5c0f\u7684\u65f6\u5019\u3002<\/p>\n<p>\u5e94\u7528\u4e8e\uff1awindow \u5bf9\u8c61<\/p>\n<p>onsubmit \u4e8b\u4ef6 \u53d1\u751f\u5728\u8868\u5355\u7684\u201c\u63d0\u4ea4\u201d\u6309\u94ae\u88ab\u5355\u51fb\uff08\u6309\u4e0b\u5e76\u653e\u5f00\uff09\u7684\u65f6\u5019\u3002\u53ef\u4ee5\u4f7f\u7528\u8be5\u4e8b\u4ef6\u6765\u9a8c\u8bc1\u8868\u5355\u7684\u6709\u6548\u6027\u3002\u901a\u8fc7\u5728\u4e8b\u4ef6\u5904\u7406\u7a0b\u5e8f\u4e2d\u8fd4\u56de false \u503c\uff08return false\uff09\u53ef\u4ee5\u963b\u6b62\u8868\u5355\u63d0\u4ea4\u3002<\/p>\n<p>\u5e94\u7528\u4e8e\uff1aForm \u5bf9\u8c61<\/p>\n<p>onunload \u4e8b\u4ef6 \u53d1\u751f\u5728\u7528\u6237\u9000\u51fa\u6587\u6863\uff08\u6216\u8005\u5173\u95ed\u7a97\u53e3\uff0c\u6216\u8005\u5230\u53e6\u4e00\u4e2a\u9875\u9762\u53bb\uff09\u7684\u65f6\u5019\u3002\u4e0e onload \u4e00\u6837\uff0c\u8981\u5199\u5728 HTML \u4e2d\u5c31\u5199\u5230body\u6807\u8bb0\u91cc\u3002<\/p>\n<p>\u6709\u7684 Web Masters \u7528\u8fd9\u4e2a\u65b9\u6cd5\u6765\u5f39\u51fa\u201c\u8c03\u67e5\u8868\u5355\u201d\uff0c\u4ee5\u201c\u5f3a\u8feb\u201d\u6765\u8005\u586b\u5199\uff1b\u6709\u7684\u5c31\u5f39\u51fa\u5e7f\u544a\u7a97\u53e3\uff0c\u5506\u4f7f\u6765\u8005\u70b9\u51fb\u8fde\u63a5\u3002\u6211\u89c9\u5f97\u8fd9\u79cd\u201conunload=&#8221;open&#8230;&#8221;\u201d\u7684\u65b9\u6cd5\u5f88\u4e0d\u597d\uff0c\u6709\u65f6\u751a\u81f3\u4f1a\u56e0\u4e3a\u5f39\u51fa\u592a\u591a\u7a97\u53e3\u800c\u5bfc\u81f4\u8d44\u6e90\u7f3a\u4e4f\u3002\u6709\u4ec0\u4e48\u5bf9\u6765\u8005\u8bf4\u5c31\u5e94\u8be5\u5728\u7f51\u9875\u4e0a\u8bf4\u5b8c\uff0c\u4e0d\u5bf9\u5417\uff1f<\/p>\n<p>\u5e94\u7528\u4e8e\uff1awindow \u5bf9\u8c61<\/p>\n","protected":false},"excerpt":{"rendered":"<p>onblur \u4e8b\u4ef6 \u53d1\u751f\u5728\u7a97\u53e3\u5931\u53bb\u7126\u70b9\u7684\u65f6\u5019\u3002 \u5e94\u7528\u4e8e\uff1awindow \u5bf9\u8c61 onchange \u4e8b\u4ef6 \u53d1\u751f\u5728\u6587\u672c [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"class_list":["post-251","post","type-post","status-publish","format-standard","hentry","category-code_related"],"_links":{"self":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts\/251","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/comments?post=251"}],"version-history":[{"count":2,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts\/251\/revisions"}],"predecessor-version":[{"id":5314,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts\/251\/revisions\/5314"}],"wp:attachment":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/media?parent=251"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/categories?post=251"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/tags?post=251"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}