-1

I want to add "Back" button functionality on my VF page. As javascript:history.back() does not work in VisualForce page, is there any other way to achieve this?

Thanks

2 Answers 2

0

Use Pagereference class. Something like this:

<apex:commandButton value="Back" action="{!back}"/>

Public pagereference back() {
Pagereference pg = new Pagereference ('/apex/NewPageName');
pg.setRedirect (true);
return pg;
}

More information on the class can be found here : https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_system_pagereference.htm

1
  • My redirection page is not vf page.I have Mass update button on Case which is overrided with VF page. So, now when I used a cancel button it should redirect back to the Case tab of list view which i have selected (same like browser back functionality).
    – teeshu
    Feb 26, 2019 at 22:55
0
<apex:commandButton value="Cancel" oncomplete="doRedirect();"/>                
          </apex:outputPanel>

            </apex:pageblockSection>
            <script type="text/javascript">
                function doRedirect(){
                    window.history.back();
                }

            </script>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.