when submitting a form in php i am using: "header('Location: contact.php');" to redirect back to the current page after hitting submit. However the form is at the bottom of the page and each time submit is hit it is redirected back to the top of the page. is there anyway to redirect back to the bottom of the page?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Yes, You can take a id to part of a page you want to return to and then return to it, see following code:
for example you want to return to bellow div:
<div id="bottom"></div>
your php code to redirect to this:
header('Location: contact.php#bottom');
回答2:
You could check if your page was the pre ious page with window.history and if so, scroll down with window.scroll to.
I really recommend to not to that and use AJAX