Html 提交后旧的 Google 表单重定向
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6077054/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Old Google Form redirect after submission
提问by Boco
I am looking for a solution (code) how to redirect user to a custom thank you page (not default Google's) after submitting the form with Old Google Form.
我正在寻找一种解决方案(代码),如何在使用旧 Google 表单提交表单后将用户重定向到自定义感谢页面(不是默认的 Google 页面)。
<iframe name="hidden_iframe"
id="hidden_iframe"
style="display:none;"
onload="if(submitted){window.location='http:/...yourthankyoupage.htm';}">
</iframe>
<form action="https://spreadsheets.google.com/formResponse?formkey=....."
method="post"
target="hidden_iframe"
onsubmit="submitted=true;">
This code is not working. At least not for me. Any suggestions?
此代码不起作用。至少对我来说不是。有什么建议?
回答by tronjavolta
is this a form that you've styled yourself? some good reading here: http://morning.am/tutorials/how-to-style-google-forms/
这是你自己设计的表格吗?这里有一些不错的阅读:http: //morning.am/tutorials/how-to-style-google-forms/
basically its... replace
基本上它的...替换
<form action="YOUR-EMBEDDED-GOOGLE-SPREADSHEET-LINK" method="POST">
with
和
<script type="text/javascript">var submitted=false;</script>
<iframe name="hidden_iframe" id="hidden_iframe" style="display:none;"
onload="if(submitted) {window.location='whateveryourredirectis.html';}"></iframe>
<form action="YOUR-EMBEDDED-GOOGLE-SPREADSHEET-LINK" method="post" target="hidden_iframe"
onsubmit="submitted=true;">
回答by bibstha
Sneaky Sheep version 2can automatically generate the necessary html to embed the form in your website. It preserves the stylesheets of your form.
Sneaky Sheep 版本 2可以自动生成必要的 html 以将表单嵌入您的网站。它保留了表单的样式表。
Or, if you're using the original version of Sneaky Sheep, make sure to append the proper domain name in the styles section to get the stylesheets.
或者,如果您使用的是 Sneaky Sheep的原始版本,请确保在样式部分附加正确的域名以获取样式表。
For example, I had to change
例如,我不得不改变
<link href='/static/forms/client/css/1234-formview_ltr.css' type='text/css' rel='stylesheet'>
to
到
<link href='https://docs.google.com/static/forms/client/css/3904611051-formview_ltr.css' type='text/css' rel='stylesheet'>
回答by Juuso Ohtonen
You could also consider other options. After putting countless hours on trying to crank Google Forms to suit my needs, I had to give up. I tried both the morning.amtutorial as advised in the first answer, and the code generator in the other one. In both cases, I copied the Google Forms code to my own web page but ended up breaking the Submit
button. This is also commented by other users on Sneaky Sheep code generator.
您也可以考虑其他选择。在花了无数个小时尝试调整 Google 表单以满足我的需求之后,我不得不放弃。我尝试了第一个答案中建议的Morning.am教程和另一个答案中的代码生成器。在这两种情况下,我都将 Google 表单代码复制到我自己的网页,但最终破坏了按钮。这也是其他用户在Sneaky Sheep 代码生成器上的评论。Submit
Apparently Google Forms is notdesigned to provide any customized feedback for the person who filled in the form. You could have a static text or even link on the confirmation page, but in my use case, the content of the confirmation page depends on the user's input.
显然,Google 表单的设计目的不是为填写表单的人提供任何定制的反馈。您可以在确认页面上添加静态文本甚至链接,但在我的用例中,确认页面的内容取决于用户的输入。
My current workaround is to ditch Google Forms entirely, and build the query form on my own. I'm using a bootstrap form generator, for example http://bootsnipp.com/forms. The downside is that I'll have to spend more time on tweaking the visual appearance of the form myself. I'll update this answer if a better solution comes around.
我目前的解决方法是完全放弃 Google 表单,并自行构建查询表单。我正在使用引导程序表单生成器,例如http://bootsnipp.com/forms。缺点是我必须花更多时间自己调整表单的视觉外观。如果出现更好的解决方案,我会更新此答案。