Skip to content Skip to sidebar Skip to footer

Back Button Not Working After Javascript Redirect

I have a widget which is embedded in random sites. when the user clicks I call the server to update the click occured and the server returns redirect to the correct page. The probl

Solution 1:

You cannot go back to a page that auto-redirects. That's just a broken back button and a frustrated user.

User goes to page A.
User clicks on link to page B.
Page B automatically redirects to page C with window.location.
User hits back button and momentarily goes back to page B.
Page B automatically redirects to page C with window.location.
User hits back button and momentarily goes back to page B.
Page B automatically redirects to page C with window.location.
User is sad.

Obviously this doesn't work. It has to work like this instead:

User goes to page A.
User clicks on link to page B.
Page B automatically redirects to page C with window.location.replace().
User hits back button and goes back to page A.
User is happy.

You must auto-redirect with window.location.replace() if you want the back button to work.

Post a Comment for "Back Button Not Working After Javascript Redirect"