如果您使用的是联系人表单7的AJAX版本(默认),那么您可以订阅
wpcf7mailsent
完成时触发的自定义事件,然后设置
top
框架例如:
<script>
document.addEventListener( 'wpcf7mailsent', function( event ) {
window.top.location = 'http://example.com/thank-you/';
// Or if the parent window is not the top window, you can use
// window.parent.location = 'http://example.com/thank-you/';
}, false );
</script>
官方文件:
https://contactform7.com/redirecting-to-another-url-after-submissions/
编辑:
event
参数对象。例如,仅在特定表单的情况下重定向:
document.addEventListener( 'wpcf7mailsent', function( event ) {
if (event.detail.contactFormId == 12) {
window.top.location = 'http://example.com/thank-you/';
}
}, false );
资料来源:
https://contactform7.com/dom-events/