页面加载流产的Javascript事件

问题描述 投票:1回答:1

我有一个Paypal付款链接页面,我的页面使用location.href将用户重定向到付款页面。但是,如果他用浏览器停止按钮中止页面,我想显示带有链接的消息。如何获取页面加载停止事件?

javascript browser abort
1个回答
0
投票

您可以使用document.onstop

在用户中止加载文档时发生。如果发生onstop事件,则不会在文档上触发onload事件。

     document.onstop = OnStopDocument;
        function OnStopDocument () {
            alert ("The loading of the document has been aborted.");
        }
        function OnLoadDocument () {
            alert ("The document has been loaded.");
        }
<body onload="OnLoadDocument ()">
   Loading the document
</body>
© www.soinside.com 2019 - 2024. All rights reserved.