在用户提交表单后重定向用户
Redirecting users after they submit a form
我试图使一个基本的形式,重定向用户到任何给定的网页,我选择后,他们提交他们的响应。尽管action元素位于我无法操作的站点上。
我该怎么做呢?
<form method="POST" action="https://docs.google.com/forms/d/1dAp52ALtiu8tEt8UY-Rs7WcKn36pI1vBItmGl0sV0Ik/formResponse">
<input type="text" name="entry.139518212" value="">
<input type="submit" name="submit" value="Submit">
</form>
Ajax可能对您有帮助。您可以通过Ajax提交表单,获取响应并做任何您想做的事情。你必须创建一个ajax函数并在点击事件
时调用它<input id="text" type="text" name="entry.139518212" value="">
<input type="submit" name="submit" value="Submit" onclick="sendData();">
然后创建一个js函数:
function sendData(){
///getting text from input
text=document.getElementById('text').value;
var xmlhttp;
///browser compatibility
if (window.XMLHttpRequest){
xmlhttp=new XMLHttpRequest();
}else{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
///if response was retrieved and no errors occured
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
///you can access the response
///put your redirection code here
}
}
xmlhttp.open("POST","https://docs.google.com/forms/d/1dAp52ALtiu8tEt8UY-Rs7WcKn36pI1vBItmGl0sV0Ik/formResponse",true);
xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
xmlhttp.send("entry.139518212="+text);
}
试试这个。您需要使用jQuery才能使其工作。
<script type="text/javascript">
$(function() {
$('form').submit(function(){
$.post('https://docs.google.com/forms/d/1dAp52ALtiu8tEt8UY-Rs7WcKn36pI1vBItmGl0sV0Ik/formResponse', function() {
window.location = 'http://www.whereveryouwanttogo.com';
});
return false;
});
});
</script>
From HTML Form Redirect
相关文章:
- 对auth.logout的Facebook事件订阅仅选择性地将用户重定向到url
- 如何通过ajax调用将用户重定向到页面
- Iframe提交并将用户重定向回原始页面,但Iframe似乎仍然存在
- 将用户重定向到 Windows 8 中的桌面浏览器
- 记住所选内容并将用户重定向到已访问的子域
- 重定向“如果确认了电子邮件,则将用户重定向到登录页”
- 如何通过扩展在chrome中单击时将用户重定向到新链接
- 当应用程序没有安装时,如何将用户重定向到(android,ios)市场
- 按下浏览器后退按钮时将用户重定向到其他页面
- 使用javascript基于登录用户重定向URL链接
- 在用户允许 Facebook 应用后,将用户重定向到动态页面
- 将用户重定向到上一页
- 防止 iframe 中的恶意 Flash 广告将用户重定向到顶部位置
- 将用户重定向到存储在变量(Javascript)中的URL
- 如何在 Javascript 警报/会议框之后将用户重定向到新网页
- 如何在会话令牌过期时将用户重定向到登录页面
- 将移动用户重定向到应用程序下载一次
- 如何在express odeJS中从post请求中获取数据,并在提交后将用户重定向到html文件
- 如果未经身份验证,请将用户重定向到登录页
- 在React中,我如何将用户重定向回状态已更改的索引