简体   繁体   English

联系表单重定向延迟

[英]Contact form redirect delay

I am working on a WordPress website contact form .我正在处理 WordPress 网站contact form Where I would like to redirect the page after the user press the send button and also a 5-sec delay .我想在用户按下发送按钮并5-sec delayredirect页面。

The following code works fine with the redirecting but I also would like to wait 5 sec before the redirecting.以下代码适用于redirecting ,但我也想在重定向前等待5 sec

  <script>
    document.addEventListener( 'wpcf7mailsent', function( event ) {
      location = 'https://www.inext.se/career/';
    }, 5000 );
    </script>

Do anyone knows what I am doing wrong here and why it is redirecting perfectly but not delaying 5 sec .有谁知道我在这里做错了什么以及为什么它可以完美redirecting但不会delaying 5 sec

To redirect a user after a certain period use a setTimeout :要在一段时间后重定向用户,请使用setTimeout

document.addEventListener("wpcf7mailsent", function() {
  setTimeout(function() {
    window.location = 'https://www.inext.se/career/'
  }, 5000);
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM