154 questions
1
vote
0
answers
213
views
history.pushState without user interaction causes popstate not to trigger in Firefox – how to fix this?
I'm using history.pushState to change the URL programmatically without any user interaction (like a button click). This works fine in Chrome and some other browsers, but in Firefox, when I press the ...
1
vote
0
answers
28
views
JS issue to detect anchor links having a hashtag value
I'm developing a website with page transitions (similar to AJAX) using history's API popstate event.
On the website, I also use HTML anchor links <a> with the href value only containing a ...
1
vote
0
answers
115
views
How to work with back and forward when I use pushState?
I use pushState to change url.
But with this method of changing the URL, I can't normally work with back and forward. Is Is there a way to make pushState work with back/forward just like with routing ...
2
votes
0
answers
2k
views
How to listen to the `popstate` event in a NextJS App Router project
I'm developing a Next.js application using the App Router.
I want to listen to the popstate event and call the preventDefault method on the event object to display the browser warning popup before the ...
0
votes
1
answer
93
views
Confirmation Modal in Infinite Loop on Browser Back Button
I'm trying to implement a confirmation modal that appears when the user tries to navigate away from a page with unsaved changes. The modal correctly appears when the browser's back button or a "...
1
vote
2
answers
2k
views
Popstate not firing before react UseEffect cleanup
I have a more complex setup, but have boiled my hook down to the most minimum example:
import { useEffect } from "react";
const useUnsavedChangesAlert = () => {
useEffect(() => {
...
1
vote
1
answer
731
views
window popstate event not firing in latest chrome version(122)
I have noticed that in the latest Chrome version(122), window.popstate event does not fire when we click the browser back/forward multiple times.
I am trying to prevent the back/forward click in my ...
1
vote
1
answer
627
views
Trying to make a single page application using window.onpopstate
I have something like a single page web application. To handle a back button click from the user I use the 'popstate' event
Here it is:
window.addEventListener('popstate', function () {
...
0
votes
0
answers
1k
views
'popstate' event not firing when clicking back button in Chrome
I have something like a single page web application. To handle a back button click from the user I use the 'popstate' event:
I have something like a single page web application. To handle a back ...
1
vote
0
answers
151
views
Confirm leaving the page in an ArcGIS web app builder
I created an app with ESRI ArcGIS Web App Builder. Now I want to ask the user if he wants to leave the page any time he clicks the forward or back button of the browser or if he refreshes the page.
I ...
0
votes
0
answers
473
views
Why is the popstate event handler not working?
I have registered the popstate event as a listener in JS, but only in Safari on My Mac it does not fire when the back button is pressed; in Chrome and Firefox it fires.
My Safari version is 16.3 (...
0
votes
1
answer
1k
views
I have to click back button twice to go back when using custom navigation in React.js
I am trying to build a global navigation system for my React app where I store the states in local storage and URL. now when I need to go back, the first time when I click back it works. I restore the ...
1
vote
1
answer
882
views
How to detect user if they visited the webpage by press back button
Let say, visitor visited my website example.com and then visited other website (maybe by clicking any link of my webpage or maybe manually typing to address bar) in same tab and then he pressed ...
0
votes
0
answers
143
views
How popstate works based on browser back button
I am confused on the working fuction of popstate.
Example.com (Clicked href) -> Google.com (Pressed Back) -> Yahoo.com
(OR)
Example.com (Clicked href) -> Google.com (Pressed Back) -> ...
0
votes
0
answers
676
views
Closing a related modal when the user clicks the browser's back button
I have a simple project in which I've included a modal component that can be closed by the browser's back button. When a modal is opened, a hash appears in the URL. If the user clicks the back button, ...