[英]Javascript for url redirection on save
I was wondering what the code might be to have a form redirect you to a website when it is saved. 我想知道保存表单时将表单重定向到网站的代码可能是什么。
Java code on the form is: 表单上的Java代码是:
<script language="JavaScript">
function saveRadioButton(radioVal, hiddenId)
{
var hidden = document.getElementById(hiddenId);
hidden.value = radioVal;
}
</script>
Once saved I would like it to send you to x website.... 保存后,我希望将您发送到x网站。
First Java != JavaScript. 第一个Java!= JavaScript。 Two different animals.
两种不同的动物。
For JavaScript it's as simple as 对于JavaScript,它就像
window.location = "http://www.google.com/"
A simple Google search shows this... 一个简单的Google搜索显示了这一点...
http://www.tizag.com/javascriptT/javascriptredirect.php http://www.tizag.com/javascriptT/javascriptredirect.php
So assuming you want to submit the value you've just set to hidden
: 因此,假设您要提交的值只是设置为
hidden
:
<form id="myForm" method="GET" act="http://google.com">
Assuming the id of your form is "myForm" and the hidden input element lies inside this form. 假设表单的ID为“ myForm”,并且隐藏的输入元素位于此表单内。 In JS:
在JS中:
document.getElementById("myForm").submit();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.