You need to sign in to do that
Don't have an account?

Need help with a "Back" button on a VF page
I am trying to make a very simple VF page that shows some text and a "Back" button. I can't figure out the "Back" button. Can someone help fix this code? Thanks!
<apex:page standardController="Opportunity"> <h1>You need to create an Opportunity directly from a Contact.</h1> <apex:form> <apex:commandButton value="Cancel" oncomplete="doRedirect();"/> <script type="text/javascript"> function doRedirect(){ window.history.back(); } </script> </apexform> </apex:page>
Everything looks fine except line 15. Change to </apex:form> (Missing Colon). Also when your testing the code how are you testing this. If you directly click on preview button this will open your VF page in brand new window which doesn't have any previous history window and you can't see if your Cancel button is working.
If you want to test it try pasting the VF page URL into another existing window and click your Cancel button which will navigate to previous window.
Hope this helps! Please mark as solved if it does
Thanks
All Answers
Everything looks fine except line 15. Change to </apex:form> (Missing Colon). Also when your testing the code how are you testing this. If you directly click on preview button this will open your VF page in brand new window which doesn't have any previous history window and you can't see if your Cancel button is working.
If you want to test it try pasting the VF page URL into another existing window and click your Cancel button which will navigate to previous window.
Hope this helps! Please mark as solved if it does
Thanks