Automatically scroll down after submit action

前提是你 提交于 2019-12-08 20:28:27

问题


How to make my website automatically scroll down after sending e-mail from "Contact Form" which is located on the bottom of my webpage? Information about successful sending or error ouccurs below the form and after clicking that 'submit' button page is refreshing and user can see only top of the site, not the bottom...


回答1:


<form id="form" action="{your_action}#form">
....
</form>



回答2:


Post to an anchor tag on the page the sumbit is being sent to

 http://foo.com#youranchor



回答3:


The action within this opening form tag works for my site:

<form action="<?php $location = $_SERVER['PATH_INFO']; 
echo ''.$location.'#form';?>" method="post">

Essentially, you're acquiring the current URL and assigning it to $location, then echoing that out with #form tagged on the end. So the browser would read this action as:

action="currentURL.php#form"

I did it this way because my form is an include found on every page of my website, so the action needed to identify its current location before scrolling down to the form.



来源:https://stackoverflow.com/questions/22027170/automatically-scroll-down-after-submit-action

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!