function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
GoForceGoGoForceGo 

Display a Thank you page before redirect.

I have a visualforce sites form. When the visitor clicks the submit button, I save the information in the database and then redirect the user to a landing page (e.g www.example.com). I would like to ideally display a "Thank you" page for 5 seconds that confirms that the form was submitted before doing the redirect.
 
VF Page:

             <apex:pageBlockButtons > 
                <apex:commandButton action="{!Submit}" value = "Submit" />  
            </apex:pageBlockButtons>

    
Apex Code;

public pagereference Submit() { 
         
   //save to db code first
   //redirect now 
   landingPage = new PageReference('http://www.example.com');
   landingPage.setRedirect(true);
   return landingPage;

}


 
Best Answer chosen by GoForceGo
mjohnson-TICmjohnson-TIC
I would probably creat a thankyou page and have the submit button go to it. You can then include a javascript snipplet at the top of the thankyou page to redirect to another url after 5 seconds.

<script type="text/javascript">
    window.setTimeout("redirectpage();", 5000);    
    function redirectpage(){
    window.top.location.href = 'http://www.redirectpageurl.com';
    }
</script>

All Answers

mjohnson-TICmjohnson-TIC
I would probably creat a thankyou page and have the submit button go to it. You can then include a javascript snipplet at the top of the thankyou page to redirect to another url after 5 seconds.

<script type="text/javascript">
    window.setTimeout("redirectpage();", 5000);    
    function redirectpage(){
    window.top.location.href = 'http://www.redirectpageurl.com';
    }
</script>
This was selected as the best answer
GoForceGoGoForceGo
Thanks! this solution works.