簡體   English   中英

重定向到用戶來自的頁面

[英]Redirect to the page where user came from

我有一個帶表單的自定義頁面模板。 此表單使用短代碼顯示在許多頁面中。 當用戶單擊提交按鈕時,用戶將重定向到“謝謝”頁面。 這個感謝頁面是一個帶有a href的靜態(使用WP頁面編輯器創建)。 現在,當用戶點擊a href (在感謝頁面中找到時,他/她將重定向到用戶提交表單的頁面URL,但是在用戶來自的頁面的特定部分。但我不知道我知道怎么做。有人可以幫我這個嗎?

<form method="POST">
    <span class="icon-pp-green-ribbon"></span>
    <fieldset>
        <div class="form-group">
            <label for="customer_fname"><span class="icons-asterisk"></span> Your name:</label>
            <input type="text" name="name_first" placeholder="" required/>
        </div>
        <div class="form-group">
            <label for="customer_tsname"><span class="icons-asterisk"></span> Your surname:</label>
            <input type="text" name="name_last" placeholder="" required/>
        </div>
        <div class="form-group">
            <label for="email">Your e-mail:</label>
            <input type="email" name="email" placeholder="@"/>
        </div>
        <div class="form-group">
            <label for="phone"><span class="icons-asterisk"></span> Phone number:</label>
            <input type="text" name="phone" pattern ="^09\d{9}$" onkeypress="return isNumberKey(event)" size="11" placeholder="09" required/>
        </div>
        <div style="margin-top: 1.50em;">
            <input type="checkbox" id="utm_checked" checked style=" float: left; transform: scale(1.2);"/>
            <label for="utm_checked">I want to be occasionally notified</label>
        </div>
        <div class="form-group">
        <input type="submit" name="submit" value="Send"/>
        </div>
    </div>
</form>

試試這個按鈕可能在這里說

<input action="action" type="button" value="Back" onclick="window.history.go(-1); return false;" />

如果您的上一頁網址沒有www.yoursite.com/somePage#someSection等網頁版塊信息,您可以在離開該頁面之前將自定義網址推送到歷史記錄堆棧,這樣每當您返回時,您不僅會返回頁面,但也是您來自的特定部分。 您可以將自定義URL推送到瀏覽器維護的歷史堆棧, 如此處所述

嘗試使用此代碼來利用瀏覽器維護的頁面訪問歷史記錄:

<button onclick="goBack()">Go Back</button>

<script>
function goBack() {
    window.history.back();
}
</script>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM