[英]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.