我有一个带有Paypal付款链接的页面,我的页面使用location.href将用户重定向到付款页面。但是,如果他使用浏览器停止按钮中止该页面,我想显示一个带有链接的消息。 如何获取页面加载停止事件?
答案 0 :(得分: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>