{"id":3576,"date":"2024-11-10T09:16:07","date_gmt":"2024-11-10T01:16:07","guid":{"rendered":"https:\/\/fwq.ai\/blog\/3576\/"},"modified":"2024-11-10T09:16:07","modified_gmt":"2024-11-10T01:16:07","slug":"chrome-%e6%b5%8f%e8%a7%88%e5%99%a8%e5%85%b3%e9%97%ad%e6%97%b6%e4%b8%8d%e8%a7%a6%e5%8f%91-onbeforeunload-%e4%ba%8b%e4%bb%b6%ef%bc%8c%e5%a6%82%e4%bd%95%e8%a7%a3%e5%86%b3%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/3576\/","title":{"rendered":"Chrome \u6d4f\u89c8\u5668\u5173\u95ed\u65f6\u4e0d\u89e6\u53d1 `onbeforeunload` \u4e8b\u4ef6\uff0c\u5982\u4f55\u89e3\u51b3\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173106236968990.jpg\" class=\"aligncenter\" title=\"Chrome \u6d4f\u89c8\u5668\u5173\u95ed\u65f6\u4e0d\u89e6\u53d1 `onbeforeunload` \u4e8b\u4ef6\uff0c\u5982\u4f55\u89e3\u51b3\uff1f\u63d2\u56fe\" alt=\"Chrome \u6d4f\u89c8\u5668\u5173\u95ed\u65f6\u4e0d\u89e6\u53d1 `onbeforeunload` \u4e8b\u4ef6\uff0c\u5982\u4f55\u89e3\u51b3\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>Chrome onbeforeunload \u4e8b\u4ef6\u5931\u6548\uff0c\u66ff\u4ee3\u65b9\u6848<\/strong><\/p>\n<p>\u5728\u4f7f\u7528 Chrome \u6d4f\u89c8\u5668\u65f6\uff0c\u53d1\u73b0 window.onbeforeunload \u4e8b\u4ef6\u5728\u5173\u95ed\u6d4f\u89c8\u5668\u65f6\u4e0d\u89e6\u53d1\u3002\u5bf9\u4e8e\u6b64\u95ee\u9898\uff0c\u5b58\u5728\u4ee5\u4e0b\u66ff\u4ee3\u65b9\u6848\uff1a<\/p>\n<ul>\n<li><strong>beforeunload \u4e8b\u4ef6<\/strong><\/li>\n<\/ul>\n<p>\u8be5\u4e8b\u4ef6\u5728\u9875\u9762\u5373\u5c06\u5378\u8f7d\u65f6\u89e6\u53d1\uff0c\u5305\u62ec\u5173\u95ed\u6d4f\u89c8\u5668\u3001\u5207\u6362\u6807\u7b7e\u9875\u4ee5\u53ca\u4ece\u9875\u9762\u5bfc\u822a\u5230\u5176\u4ed6\u9875\u9762\u3002\u4e0d\u8fc7\uff0c\u4e0e onbeforeunload \u4e8b\u4ef6\u4e0d\u540c\uff0cbeforeunload \u4e8b\u4ef6\u65e0\u6cd5\u963b\u6b62\u9875\u9762\u5378\u8f7d\u3002<\/p>\n<ul>\n<li><strong>unload \u4e8b\u4ef6<\/strong><\/li>\n<\/ul>\n<p>\u8be5\u4e8b\u4ef6\u5728\u9875\u9762\u5378\u8f7d\u540e\u89e6\u53d1\uff0c\u4f46\u5728\u6b64\u4e8b\u4ef6\u4e2d\uff0c\u65e0\u6cd5\u963b\u6b62\u9875\u9762\u5378\u8f7d\u6216\u4fee\u6539\u9875\u9762\u3002<\/p>\n<ul>\n<li><strong>\u9875\u9762\u53ef\u89c1\u6027 API<\/strong><\/li>\n<\/ul>\n<p>\u6b64 API \u63d0\u4f9b\u9875\u9762\u53ef\u89c1\u6027\u4fe1\u606f\uff0c\u53ef\u4ee5\u4f7f\u7528\u5b83\u6765\u68c0\u6d4b\u9875\u9762\u4f55\u65f6\u8fdb\u5165\u540e\u53f0\u3002\u5f53\u9875\u9762\u8fdb\u5165\u540e\u53f0\u65f6\uff0c\u53ef\u4ee5\u663e\u793a\u4e00\u6761\u63d0\u793a\u6d88\u606f\uff0c\u8be2\u95ee\u7528\u6237\u662f\u5426\u8981\u79bb\u5f00\u9875\u9762\u3002<\/p>\n<ul>\n<li><strong>\u786e\u8ba4\u5bf9\u8bdd\u6846<\/strong><\/li>\n<\/ul>\n<p>\u53ef\u4ee5\u5728\u5173\u95ed\u6d4f\u89c8\u5668\u4e4b\u524d\u663e\u793a\u4e00\u4e2a\u786e\u8ba4\u5bf9\u8bdd\u6846\uff0c\u8be2\u95ee\u7528\u6237\u662f\u5426\u8981\u79bb\u5f00\u9875\u9762\u3002\u8fd9\u53ef\u4ee5\u5728\u7528\u6237\u9000\u51fa\u4e4b\u524d\u5411\u5176\u63d0\u4f9b\u6700\u540e\u7684\u786e\u8ba4\u3002<\/p>\n<p><strong>\u6d4b\u8bd5\u7ed3\u679c<\/strong><\/p>\n<p>\u5728 Chrome 73.0.3683.103 \u7248\u672c\u4e2d\u8fdb\u884c\u6d4b\u8bd5\u53d1\u73b0\uff1a<\/p>\n<ul>\n<li>\u76f4\u63a5\u5173\u95ed\u9875\u9762\u4e0d\u4f1a\u89e6\u53d1 onbeforeunload \u4e8b\u4ef6\u3002<\/li>\n<li>\u4e0e\u9875\u9762\u4ea4\u4e92\uff08\u5982\u5355\u51fb\u94fe\u63a5\uff09\u540e\u5173\u95ed\u9875\u9762\uff0c\u4f1a\u89e6\u53d1 onbeforeunload \u4e8b\u4ef6\u3002<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662fChrome \u6d4f\u89c8\u5668\u5173\u95ed\u65f6\u4e0d\u89e6\u53d1 `onbeforeunload` \u4e8b\u4ef6\uff0c\u5982\u4f55\u89e3\u51b3\uff1f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Chrome onbeforeunload \u4e8b\u4ef6\u5931\u6548\uff0c\u66ff\u4ee3\u65b9\u6848 \u5728\u4f7f\u7528 Chrome \u6d4f\u89c8\u5668\u65f6\uff0c\u53d1\u73b0 window.onbeforeunload \u4e8b\u4ef6\u5728\u5173\u95ed\u6d4f\u89c8\u5668\u65f6\u4e0d\u89e6\u53d1\u3002\u5bf9\u4e8e\u6b64\u95ee\u9898\uff0c\u5b58\u5728\u4ee5\u4e0b\u66ff\u4ee3\u65b9\u6848\uff1a beforeunload \u4e8b\u4ef6 \u8be5\u4e8b\u4ef6\u5728\u9875\u9762\u5373\u5c06\u5378\u8f7d\u65f6\u89e6\u53d1\uff0c\u5305\u62ec\u5173\u95ed\u6d4f\u89c8\u5668\u3001\u5207\u6362\u6807\u7b7e\u9875\u4ee5\u53ca\u4ece\u9875\u9762\u5bfc\u822a\u5230\u5176\u4ed6\u9875\u9762\u3002\u4e0d\u8fc7\uff0c\u4e0e onbeforeunload \u4e8b\u4ef6\u4e0d\u540c\uff0cbeforeunload \u4e8b\u4ef6\u65e0\u6cd5\u963b\u6b62\u9875\u9762\u5378\u8f7d\u3002 unload \u4e8b\u4ef6 \u8be5\u4e8b\u4ef6\u5728\u9875\u9762\u5378\u8f7d\u540e\u89e6\u53d1\uff0c\u4f46\u5728\u6b64\u4e8b\u4ef6\u4e2d\uff0c\u65e0\u6cd5\u963b\u6b62\u9875\u9762\u5378\u8f7d\u6216\u4fee\u6539\u9875\u9762\u3002 \u9875\u9762\u53ef\u89c1\u6027 API \u6b64 API \u63d0\u4f9b\u9875\u9762\u53ef\u89c1\u6027\u4fe1\u606f\uff0c\u53ef\u4ee5\u4f7f\u7528\u5b83\u6765\u68c0\u6d4b\u9875\u9762\u4f55\u65f6\u8fdb\u5165\u540e\u53f0\u3002\u5f53\u9875\u9762\u8fdb\u5165\u540e\u53f0\u65f6\uff0c\u53ef\u4ee5\u663e\u793a\u4e00\u6761\u63d0\u793a\u6d88\u606f\uff0c\u8be2\u95ee\u7528\u6237\u662f\u5426\u8981\u79bb\u5f00\u9875\u9762\u3002 \u786e\u8ba4\u5bf9\u8bdd\u6846 \u53ef\u4ee5\u5728\u5173\u95ed\u6d4f\u89c8\u5668\u4e4b\u524d\u663e\u793a\u4e00\u4e2a\u786e\u8ba4\u5bf9\u8bdd\u6846\uff0c\u8be2\u95ee\u7528\u6237\u662f\u5426\u8981\u79bb\u5f00\u9875\u9762\u3002\u8fd9\u53ef\u4ee5\u5728\u7528\u6237\u9000\u51fa\u4e4b\u524d\u5411\u5176\u63d0\u4f9b\u6700\u540e\u7684\u786e\u8ba4\u3002 \u6d4b\u8bd5\u7ed3\u679c \u5728 Chrome 73.0.3683.103 \u7248\u672c\u4e2d\u8fdb\u884c\u6d4b\u8bd5\u53d1\u73b0\uff1a \u76f4\u63a5\u5173\u95ed\u9875\u9762\u4e0d\u4f1a\u89e6\u53d1 onbeforeunload \u4e8b\u4ef6\u3002 \u4e0e\u9875\u9762\u4ea4\u4e92\uff08\u5982\u5355\u51fb\u94fe\u63a5\uff09\u540e\u5173\u95ed\u9875\u9762\uff0c\u4f1a\u89e6\u53d1 onbeforeunload \u4e8b\u4ef6\u3002 \u4ee5\u4e0a\u5c31\u662fChrome \u6d4f\u89c8\u5668\u5173\u95ed\u65f6\u4e0d\u89e6\u53d1 `onbeforeunload` \u4e8b\u4ef6\uff0c\u5982\u4f55\u89e3\u51b3\uff1f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-3576","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/3576","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=3576"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/3576\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=3576"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=3576"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=3576"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}