JavaScript Jump to top of page on form submit to new page

I have a form on a PHP page :

<form name="SendEmail01" method="post">
    form items here...
</form>

I then process it like this:

if(isset($_POST["Submit"]))
{
All tasks here...
$thanks_redirect = 'http://' . $_SERVER["SERVER_NAME"] . '/thanks.php#top';
header("location: $thanks_redirect");
}

The issue is that the submit button on the processing page is quite low down on the page and when I press 'Submit' it all processes correctly and jumps to the thanks.php page correctly, but the page stays in the same location and it looks like its just a blank page (unless the user scrolls up).

I have tried Javascript and HTML hyperlinks such as #top but it will just not jump back to the top of the page where, on the thanks.php page, it says that it has all been processed correctly.

Could anyone please help with how I get the thanks.php page to scroll back to the top of the page once the form has been processed?

Edit : I have this on the thanks.php page where the user is redirected on submission:

<html>
<head>
<script type="text/javascript">
var lockit=setInterval("window.scrollTo(0,0)",10)
</script>
<style>
form {
    display: inline;
}
input
{
color: #000000;
background: #ffffff;
border: 1px solid #000000;
padding: 4px;
font-size:13px;
font 
}
#submit {
 color: #000000;
 font-size: 13px;
 width: 110px;
 height: 30px;
 border: 1px solid #000000;
 margin: 0;
 padding: 0;
 background: #66ff66 url(image) 0 0 no-repeat; 
}
#buttons {
 color: #000000;
 font-size: 13px;
 width: 80px;
 height: 25px;
 border: 1px solid #000000;
 margin: 0;
 padding: 0;
 background: #66ff66 url(image) 0 0 no-repeat; 
}
</style>

</head>
<body>
<script type="text/javascript">
$('html, body').animate({ scrollTop: 0 }, 'fast');
</script>
<?php
session_start();
$loggedin_user = $_SESSION['serial'];
$local_path = $_SESSION['local_path'];
$full_path = $_SESSION['full_path'];
?>
<font face="Verdana, Arial, Helvetica, sans-serif" color="black">

<form action="http://<?php echo $_SERVER["SERVER_NAME"]; ?>/login.php?log_out">
    <input type="submit" value="Logout" id="buttons">
</form>
<form action="<?php echo $full_path;?>index.php">
    <input type="submit" value="Go Back" id="buttons">
</form>
<p><b>Success!</p></b>
<p>Your changes have been submitted.. 

<p>Please note that not <u>all</u> changes are made in real-time, some changes may only be updated when the server checks for new configuration.</p>

</body>
</html>

Thank you.

Answer:1

I'd add this as a comment, but it's a bit too long for it.

I made this page:

<!DOCTYPE html>
<html>
<head>
</head>

<body>

    <p>Calibri Text</p>
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <form>
        <input type="submit" />
    </form>

</body>
</html>

On submission, the page jumps to the top along with a redirect to another page, so you shouldn't be having this issue less there is something in your jQuery giving something focus.

Answer:2

the problem is simple, document.getElementsByTagName('*') does not select the SVG tag and in the console it gives an error. But if I erase the SVG labels, works correctly. My Code: var Master = ...

the problem is simple, document.getElementsByTagName('*') does not select the SVG tag and in the console it gives an error. But if I erase the SVG labels, works correctly. My Code: var Master = ...

  1. document getelementsbytagname java
  2. document getelementsbytagname innerhtml
  3. document getelementsbytagname w3schools
  4. document getelementsbytagname multiple tags
  5. document getelementsbytagname radio button
  6. document.getelementsbytagname('video') 0 .request picture in picture()
  7. document.getelementsbytagname(name)
  8. document.getelementsbytagname is not a function
  9. document.getelementsbytagname('body')
  10. document.getelementsbytagnamens
  11. document.getelementsbytagname(...).addeventlistener is not a function
  12. document.getelementsbytagname( input )
  13. document.getelementsbytagname foreach
  14. document.getelementsbytagname(...).appendchild is not a function
  15. document.getelementsbytagname( body ) 0
  16. document.getelementsbytagname('head') 0 .appendchild(script)
  17. document.getelementsbytagname jquery
  18. document.getelementsbytagname js
  19. document.getelementsbytagname('base') 0 .href
  20. document.getelementsbytagname('script') 0

There is a function that returns an array according to the second argument (if the country is Japan, it will return only brands of cars from Japan). Is it possible to improve the function using only ...

There is a function that returns an array according to the second argument (if the country is Japan, it will return only brands of cars from Japan). Is it possible to improve the function using only ...

  1. method filter javascript
  2. method filter js
  3. method filter does not exist
  4. method filter java
  5. method filter python
  6. method filter aris
  7. method filter scala
  8. method filter array
  9. method filter swift
  10. method filter in r
  11. filter method feature selection
  12. filter method of ssb generation
  13. filter method in java 8
  14. filter method in typescript
  15. filter method in jquery
  16. filter method in angular 6
  17. filter method in react
  18. filter method in angular
  19. filter method in react js
  20. filter method array javascript

I am working on ListControl and one of the columns has Delete link which I am formatting using HTMLTemplate as follows: <a href="javascript: app.showConfirmation()" >Delete</a> My ...

I am working on ListControl and one of the columns has Delete link which I am formatting using HTMLTemplate as follows: <a href="javascript: app.showConfirmation()" >Delete</a> My ...

I have added "domino" in the server.ts and even updated webpack.server.config.js as : module: { rules: [ { test: /\.(ts|js)$/, loader: 'regexp-replace-loader', options: { match: { ...

I have added "domino" in the server.ts and even updated webpack.server.config.js as : module: { rules: [ { test: /\.(ts|js)$/, loader: 'regexp-replace-loader', options: { match: { ...

  1. angular universal referenceerror document is not defined
  2. angular universal referenceerror window is not defined
  3. angular universal referenceerror localstorage is not defined
  4. angular universal referenceerror event is not defined
  5. angular universal referenceerror navigator is not defined
  6. angular universal referenceerror mouseevent is not defined
  7. angular ssr referenceerror document is not defined
  8. referenceerror document is not defined angular universal
  9. error referenceerror document is not defined angular universal