Custom "Back to previous page" button.

Custom "Back to previous page" button.

Hi,

I created a custom "Back to previous page" button with the following function:

  1. function goBack() {
        window.history.go(-1);
    }

Clicking on the button, brings you to the previous page. However if the page was a form, the values in the form fields aren't there any more.

How can I extend the goBack() function, so that if I go back to a form, the form field values are still there?

Thanks