OnBeforeUnload 之后有触发吗?
我想在发送表单/文件后、加载下一页之前执行一些 JavaScript。通常,我会在登陆页面上执行脚本,但它是第 3 方 API。 onbeforeunload
实际上会在提交表单后立即触发,但需要几分钟才能发送(文件上传)。
我可以使用任何触发器来代替这个吗?谢谢
I'd like to execute some javascript after a form/file was send, but before the next page loads. Normally, I would execute the script on the landing page, but it is a 3rd party API. The onbeforeunload
does actually fire as soon as the form is submitted, but it takes minutes for it to send (file upload).
Is here any trigger I could use instead of this one? Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
有
onunload
,但我不确定在这种情况下它何时触发(肯定是在onbeforeunload
之后:))请注意,
onunload
中的 AJAX 非常有用挑剔,可能永远不会执行。There's
onunload
, but I'm not sure when it fires in this case (definitely afteronbeforeunload
:))Note that AJAX in
onunload
is very finicky and may never execute.最终我创建了一个 iframe 并处理了它的
onload
事件。混乱的解决方案,因为它更糟糕,但我认为这与使用第三方页面有关。Ultimately I've created an iframe and handeled it's
onload
event. Messy solution as it's worse, but that goes with using 3rd party pages I presume.