Avoid support scams. We will never ask you to call or text a phone number or share personal information. Please report suspicious activity using the “Report Abuse” option.

Learn More

Browser back button not working without user interact in the web page

  • No replies
  • 0 have this problem
  • 26 views

Hi,

I need help resolving an issue related to browser navigation and the popstate event.

Here's the scenario:

  • The user starts on page-1.html.
  • They click a button, which navigates to page-2.html.
  • When the user presses the browser back button (without clicking any button on the page), I want to trigger a JavaScript popstate event automatically.

Currently, I'm doing the following:

  • When the user arrives at page-2.html from page-1.html, I show a popup.
  • When the user closes the popup, I manually push a state using history.pushState() to create a backward URL entry.

However, my client’s requirement is to trigger the popstate event without requiring any user interaction on page-2.html, i.e., as soon as the user presses the back button.

Is there a way to programmatically achieve this behavior (ensuring the popstate event is fired) without requiring the user to click anything on page-2.html?

Any guidance or recommended approach would be greatly appreciated.

Thank you.

Hi, I need help resolving an issue related to browser navigation and the popstate event. '''Here's the scenario:''' * The user starts on page-1.html. * They click a button, which navigates to page-2.html. * When the user presses the browser back button (without clicking any button on the page), I want to trigger a JavaScript popstate event automatically. '''Currently, I'm doing the following:''' * When the user arrives at page-2.html from page-1.html, I show a popup. * When the user closes the popup, I manually push a state using history.pushState() to create a backward URL entry. However, my client’s requirement is to trigger the popstate event '''without requiring any user interaction''' on page-2.html, i.e., as soon as the user presses the back button. Is there a way to programmatically achieve this behavior (ensuring the popstate event is fired) without requiring the user to click anything on page-2.html? Any guidance or recommended approach would be greatly appreciated. Thank you.

You must log in to your account to reply to posts. Please start a new question, if you do not have an account yet.