[英]Redirect to the same page (without PHP)
I have a form that can be called from any page. 我有一个可以从任何页面调用的表单。 It opens on top of the current page with z-index. 它使用z-index打开当前页面的顶部。 I cannot use php in this case. 在这种情况下我不能使用php。 The form is send to a cgi to process the values. 表单将发送到cgi以处理值。 It is necessary to put something in "redirect" if I leave it blank it don't works. 如果我把它留空,有必要把东西放在“重定向”中它不起作用。 In redirect is there a way to put the value to the current page whatever it is? 在重定向中有没有办法将值放到当前页面,无论它是什么?
<Form id="formulari" method="POST" action="http://cgi.domain.com/FormMail.pl">
<p>
<input type="hidden" name="recipient" value="info@domain">
<input type="hidden" name="subject" value="IB4 correu">
<input type="hidden" name="redirect" value="TheSamePageWeAre">
</p>
<form>
<input type="text" name="name" value="name"/>
<input type="submit" value="Send"/>
</form>
Put this javascript at the end of the page. 把这个javascript放在页面的末尾。
<script type='text/javascript'>
document.getElementsByName('redirect')[0].value = window.location.pathname;
</script>
Set an id
on the hidden field, for example id="redirect"
, and use this Javascript: 在隐藏字段上设置id
,例如id="redirect"
,并使用此Javascript:
<script>
window.onload = function (){
document.getElementById('redirect').value = location
}
</script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.