简体   繁体   中英

Automatically scroll down after submit action

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...

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

发送到页面上的锚标签,发送sumbit

 http://foo.com#youranchor

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM