How to Reload the Page Using an ActionPRO

Reload or refreshing a page can be useful if, for example, you are using a form to edit a post and the form is on the post itself. Reloading a page is easy to do using some simple JavaScript. The JavaScript is as follows:

location.reload();

Using the Run JavaScript Action

The Run JavaScript action can be used to run the reload method. To do this:

  1. When editing your form, click the Actions icon at the top of the page. The Actions sidebar will open on the side of the page.
  2. Click the Add  icon to add a new action.
  3. Select JavaScript from the Action pulldown.
  4. Is the JavaScript setting, enter location.reload();.
  5. Click Save & Close.
  6. Publish your form.

WS Form - Run JavaScript Action - Reload Page

Now when the form is submitted, the page will reload.

Note that reloading and redirecting a web page may prevent other JavaScript on the page from running, e.g. analytics events.

Using Conditional Logic

JavaScript can also be run using conditional logic. For example you could run JavaScript with a custom button is clicked. To do this:

  1. Click the Conditional Logic icon at the top of the layout editor. The Conditional Logic sidebar will open.
  2. Click the Add  icon to add a new condition.
  3. When editing THEN, choose Form > Run JavaScript.
  4. Enter location.reload();.
  5. Click Save & Close.
  6. Publish your form.

WS Form - Conditional Logic - Run JavaScript - Reload Page

In the above example the page would be reloaded each time the custom button is clicked. Clicking the button would clear any data entered into the form at that point.

Bypassing The Browser Cache

Should you encounter an issue where the page content does not reload correctly, it may be due to the browser cache retrieving a cached version of the page. To address this, you can ensure a fresh reload by setting the forceGet parameter to true in the reload method, as demonstrated below:

location.reload(true);