Javascript 使用iFrame作为目标的表单在重新访问页面时重新提交
我已经用谷歌表单在我的网站上创建了一个表单,通过一些教程,我阻止了该页面导航到谷歌表单感谢页面,而是使用我自己的感谢页面Javascript 使用iFrame作为目标的表单在重新访问页面时重新提交,javascript,html,forms,iframe,Javascript,Html,Forms,Iframe,我已经用谷歌表单在我的网站上创建了一个表单,通过一些教程,我阻止了该页面导航到谷歌表单感谢页面,而是使用我自己的感谢页面 <iframe name="hidden_iframe" id="hidden_iframe" style="display:none;" onload="if(submitted == true) {window.location='https://www.normadorothy.com/sample-thanks';}"> </iframe&
<iframe name="hidden_iframe" id="hidden_iframe"
style="display:none;" onload="if(submitted == true)
{window.location='https://www.normadorothy.com/sample-thanks';}">
</iframe>
这样做的方式是使用隐藏的iframe作为表单上的目标,然后iframe在将窗口切换到my thank you page之前检查表单是否已成功提交
<iframe name="hidden_iframe" id="hidden_iframe"
style="display:none;" onload="if(submitted == true)
{window.location='https://www.normadorothy.com/sample-thanks';}">
</iframe>
validate函数检查所有字段,将submitted
设置为true,然后提交表单
任何帮助都会很好,我一直用这个把头撞在墙上 我猜这是因为“后退”按钮试图将您带回iFrame的最后一个已知状态(即表单POST URL),而不是您期望的“原始”状态。您可以尝试在父页面上使用JS编写iFrame,以解决以下问题:
var iframe = document.createElement('iframe');
iframe.onload = function() { if(submitted == true) {window.location='https://www.normadorothy.com/sample-thanks';}};
iframe.style.display = 'none';
document.body.appendChild(iframe);
谢谢你的帮助:)刚刚尝试了这个,但不幸的是没有成功!