gpt4 book ai didi

javascript - 如何绕过 FormSpree 重定向?

转载 作者:太空狗 更新时间:2023-10-29 13:57:18 24 4
gpt4 key购买 nike

我在 Github Pages 服务上建立了我的网站。我正在尝试实现 FormSpree 免费联系表格,但在您提交表格后,它会将您重定向到另一个网站。我想避免的事情。所以我在网上查了一下,当然其他人也想摆脱它(我在下图中省略了我的电子邮件)。

enter image description here

这是我在上面得到的表格,但它实际上根本不起作用。不过,在我尝试摆弄它之前它就起作用了。

这是 FormSpree 默认情况下的表单:

<form action="//formspree.io/your@email.com"
method="POST">
<input type="text" name="name">
<input type="email" name="_replyto">
<input type="submit" value="Send">
</form>

这是我的版本(在我尝试绕过重定向之前运行良好)

<div class=modal-body style="background-color: #454545">
<p>Please use the form below to contact us regarding feedback or any questions you may have!
We will never use the information given below to spam you and we will never pass on your
information to a 3rd party.</p>
<p>As we are using <a target="_blank" href="http://formspree.io">FormSpree</a> for this form
please consult their privacy policy for any questions regarding this matter.</p>
<form id="contactform" method="POST">
<div class="form-group">
<div class="input-group">
<span class="input-group-addon">Name</span>
<input name="form-name-input" type="text" name="name" class="form-control" required>
</div>
<div class="input-group">
<span class="input-group-addon">Email</span>
<input name="form-email-input" type="email" name="_replyto" class="form-control" required>
</div>
<div class="input-group">
<span class="input-group-addon">Subject</span>
<input name="form-subject-input" type="text" name="subject" class="form-control" required>
</div>
<div class="input-group">
<span class="input-group-addon">Description</span>
<textarea name="form-description-input" name="description" class="form-control" rows="4" cols="60" required></textarea>
</div>
<input type="text" name="_gotcha" style="display:none" />
<input class="btn btn-success" data-dismiss="modal" type="submit" id="form-submit-btn" value="Submit">
<input type="hidden" name="_next" value="http://www.dynamicrealities.net" onclick="FormSentConfirmation()"/>
</div>
<script>
var contactform = document.getElementById('contactform');
contactform.setAttribute('action', '//formspree.io/' + 'dynamicrealities@gmail.com');
</script>
</form>
</div>
<div class="modal-footer" style="background-color: #333333">
<button class="btn btn-danger btn-bg" data-dismiss="modal" type="button" id="form-dismiss-btn" onclick="">Close</button>
</div>

当我调用 _next 时,我希望它执行以下警报:

function FormSentConfirmation() {
alert('Thanks for the email, we\'ll be in touch promptly.');
}

当我按下“提交”按钮时,发生的只是表单消失但我没有收到任何电子邮件。我可能只是做错了,因为我对 HTML/JavaScript 还很陌生。

最佳答案

更新:该功能仅适用于付费计划。

在表单提交后使用表单中的这个隐藏输入字段进行重定向。您可以将用户重定向到您喜欢的页面或您使用此代码块创建的页面。

<input type="hidden" name="_next" value="//site.io/thanks.html" />

替换为有效的感谢页面 URL。

点击此链接获取有关 how to use Formspree 的教程还有一个video demo

关于javascript - 如何绕过 FormSpree 重定向?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33984667/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com