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