我有一个由PHP处理的表单,它通过使用Location:头将访问者重定向到第三方支付系统。表单处理速度很快,但当涉及到支付系统(Paypal)时,需要3-5秒来建立HTTPS连接并完成重定向。
我试图通过显示一个带有“请稍候”消息的弹出窗口(JQuery Colorbox插件)来改善访问者体验,如下所示:
$('a.submit').click(function(event) {
event.preventDefault();
$(this).colorbox({
href: '#order_redirect',
title: 'Sending data to a payment system',
inline: true,
fixed: true
});
$(this).closest('form').submit();
});Colorbox的默认行为是您可以按Esc键并关闭弹出窗口。我想让用户这样做,并通过回调函数停止重定向(Javascript在整个过程中继续工作)。有可能吗?在浏览器实际接收到报头之后可能需要几秒钟。
发布于 2011-10-07 14:27:35
我很难测试这是否会停止重定向,但这应该是一个很好的开始。
$('a.submit').click(function(event) {
event.preventDefault();
$(this).colorbox({
href: '#order_redirect',
title: 'Sending data to a payment system',
inline: true,
fixed: true,
onClosed:function() {
history.go(-1);
}
});
$(this).closest('form').submit();
});发布于 2011-10-09 16:21:44
通过回调函数停止重定向
我认为这是不可能的。您能做的最好的事情就是将位置改回当前页面,或者使用location.reload()。但是,如果您是通过ajax提交表单,则可以中止表单:
https://stackoverflow.com/questions/7683586
复制相似问题