简体   繁体   中英

Previous page not loading after clicking browser back button after a page redirection

From a sign up success thanks page I am redirecting to another webpage using window.location object. But after redirecting, clicking browser back button shows the sign up page not the sign up success thanks page. Tried the same scenario without pressing the back button instead used window.history.go(-1) , this works fine it loads the success thanks page itself.

Use window.location.href = 'YOUR LINK'

Right now, you are replacing the current page url (success page) with the new page (redirected page), so when you go back you go to the previous page in the history stack, which is the sign up page.

You can also use history.pushState() to add entries to the location history

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM