jump to mail confirmation section on page

Discussion in 'Scripts' started by Manganix, Oct 27, 2013.

to remove all ads.
  1. Manganix

    Manganix Member

    Messages:
    112
    Hi,


    when you submit a mail, you first should see the "thank you for your mail" and after this you should be redirected to the main page.

    It works, but the problem is that the "thank you" message appears on the mail-section of the page (halfway of the page) but right after you push the submit button, the top of the page is shown, before the redirection occurs, wich makes that the submitter doesn't see the confirmation of his submission -unless you scroll to the contact section of the page before the redirection, although it is shown on the screen, halfway of the page.

    I tried to put a "href to anchor" but didn't help:
    PHP:
    <?php else: ?>
                <a href="#contactArea">
                <p style="margin-left:10px; margin-top:30px; margin-bottom:0px; font-size:18px;">Thank you for your message. We appreciate your feedback!</p></a>
                <script type="text/javascript">
                setTimeout('ourRedirect()', 8000)
                function ourRedirect() {
                location.href='Index.php'
    Same issue when trying to submit without filling in the cells: the error messages 'please fill in..." appear on the screen on the contact section, but the top of the page is shown, which makes that the submitter doesn't see the error messages unless he scrolls to the contact section.

    Could you please test and advise.


    Thanks for your support.


    http://www.gamanga.com/
     
    Last edited: Oct 27, 2013
  2. chrishirst

    chrishirst Well-Known Member Staff Member

    Messages:
    2,657
    Add the document fragment marker to the redirect URI.
     
  3. Manganix

    Manganix Member

    Messages:
    112
    But the redirect that you see is correct; that is the final redirect, after the "thank you" is shown. It is redirecting as it should be to the index top.

    What I want is an other redirect, preceeding this existing one, occurring right after you push the submit-wich redirects to the contact fragment of the page, where the "thank you" appears.

    I already tried something like this, but didn't work:

    PHP:
    <?php else: ?>
    <script type="text/javascript">
                setTimeout('ourRedirect()', 0000)
                function ourRedirect() {
                location.href='Index.php#contactArea'}
                </script>
                <p style="margin-left:40px; margin-top:35px; margin-bottom:0px; font-size:16px;">Thank you for your message!</p>
                <script type="text/javascript">
                setTimeout('ourRedirect()', 4000)
                function ourRedirect() {
                location.href='Index.php'}
                </script>
                <?php endif; ?>

    Thanks.
     
  4. chrishirst

    chrishirst Well-Known Member Staff Member

    Messages:
    2,657
    You cannot have two redirects from one action, because the script will stop executing the as soon as the document URL changes.

    Just move the window to a location (Document Fragment) within the document where the message is displayed by using,

    Code:
    window.location.hash = '#ContactFormID';
    
    Before starting the timer.
     
  5. Manganix

    Manganix Member

    Messages:
    112
    thanks man! works great, for after submission and error-display in case of empty fields.
     

Share This Page