How can I build a "back" button?

I really, really, really need a simple Button that does onclick="window.history.back()"

Is there any way, trick or workaround to archive this?

If not, could you please just add the option “Navigate to → Previous Page” to the Action “Navigate to” @noloco team?

I honestly think noloco is great but the fact that i cannot build a simple “back” button feels slightly ridiculous.

Hi @_4N, you can achieve something similar with a navigation button and set it to go to whatever the previous page is. Have you tried using the Navigate to action?

Yea but this does not work for records because you can get there from different locations.

Breadcrumps are not an option because they display a link to the underlaying database which only lead to confusion in the past so we abandoned them all together for the user group in question.

Buttons on top of the page make for really nice navigational elements, especially for the mobile view. But not being able to have a dynamic “back” button cripples this approach too :confused:

Shoudn’t it be fairly easy to just allow a “dynamically go to previous page” option for the “navigate to…” action?
It would make a huge difference for building a better user experience.

@_4N - you can probably wire this up with simple Javascript, by targeting the button by it’s action-button ID.

If that’s what you’re looking to do, that is probably the best suggestion

1 Like

I finally came around trying this today and it seems to work.
Admittedly I used chat GPT to write the script so I quickly wanted to post it here and ask if an actual developer sees any issues with it.

<script>
  function attachClickHandler() {
    // List of button classes or IDs you want to target
    const buttonSelectors = [
      '.action-button-z7eyhHFdB', // First button selector
      '.action-button-C-hkxyARw'  // Second button selector (your new button)
    ];

    buttonSelectors.forEach(selector => {
      const button = document.querySelector(selector);
      if (button && !button.hasAttribute("data-click-handler")) {
        button.setAttribute("data-click-handler", "true"); // Prevents duplicate handlers
        button.onclick = function() {
          console.log("Button clicked!");
          window.history.back();
        };
      }
    });
  }

  // Run every second to ensure the buttons keep working
  setInterval(attachClickHandler, 1000);
</script>

It woudn’t work at first, after some troubleshooting it seemed that noloco was dynamically changing things in the background which caused the script to not function.

I am a bit worried the skript will cause performance issues, if that would be the case, a headsup would be appreciated.

1 Like