【问题标题】:Javascript event on page load abortion页面加载中止上的 Javascript 事件
【发布时间】:2019-03-20 12:33:32
【问题描述】:

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

【问题讨论】:

    标签: javascript browser abort


    【解决方案1】:

    您可以使用 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>

    【讨论】:

    • 这应该在调用者页面上工作吗? document.onstop 在调用者页面上不起作用
    猜你喜欢
    • 2012-05-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-04-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多