我有一个可以从任何页面调用的表单。它使用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>
答案 0 :(得分:2)
将此javascript放在页面末尾。
<script type='text/javascript'>
document.getElementsByName('redirect')[0].value = window.location.pathname;
</script>
答案 1 :(得分:0)
在隐藏字段上设置id
,例如id="redirect"
,然后使用此Javascript:
<script>
window.onload = function (){
document.getElementById('redirect').value = location
}
</script>