繁体   English   中英

重定向到同一页面(不含PHP)

[英]Redirect to the same page (without PHP)

我有一个可以从任何页面调用的表单。 它使用z-index打开当前页面的顶部。 在这种情况下我不能使用php。 表单将发送到cgi以处理值。 如果我把它留空,有必要把东西放在“重定向”中它不起作用。 在重定向中有没有办法将值放到当前页面,无论它是什么?

<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>

把这个javascript放在页面的末尾。

<script type='text/javascript'>
  document.getElementsByName('redirect')[0].value = window.location.pathname;
</script>

在隐藏字段上设置id ,例如id="redirect" ,并使用此Javascript:

<script>
  window.onload = function (){
    document.getElementById('redirect').value = location
  }
</script>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM